Row::ith_column() method removed
This commit is contained in:
30
table.cpp
30
table.cpp
@@ -60,9 +60,9 @@ std::string Table::csv_string() {
|
||||
for(int i = 0; i < m_col_defs.size(); i++) {
|
||||
if (i > 0) csv_line += ",";
|
||||
|
||||
auto col = m_row.ith_column(i);
|
||||
if (!col->isNull()) {
|
||||
csv_line += col->getStringValue(); // TODO handle enclosing commas etc
|
||||
auto & col = m_row[i];
|
||||
if (!col.isNull()) {
|
||||
csv_line += col.getStringValue(); // TODO handle enclosing commas etc
|
||||
}
|
||||
}
|
||||
out_string += csv_line;
|
||||
@@ -190,21 +190,21 @@ void Table::commit_copy_of_row(const Row &row) {
|
||||
Row& new_row = create_empty_row();
|
||||
|
||||
for(int i = 0; i < m_col_defs.size(); i++) {
|
||||
ColValue *ct = row.ith_column(i);
|
||||
ColValue &ct = row[i];
|
||||
|
||||
if (ct->isNull()) {
|
||||
if (ct.isNull()) {
|
||||
new_row.setColumnNull(i);
|
||||
} else {
|
||||
if (m_col_defs[i].type == ColumnType::integer_type) {
|
||||
new_row.setIntColumnValue(i, row.ith_column(i)->getIntValue());
|
||||
new_row.setIntColumnValue(i, row[i].getIntValue());
|
||||
} else if (m_col_defs[i].type == ColumnType::float_type) {
|
||||
new_row.setFloatColumnValue(i, row.ith_column(i)->getDoubleValue());
|
||||
new_row.setFloatColumnValue(i, row[i].getDoubleValue());
|
||||
} else if (m_col_defs[i].type == ColumnType::varchar_type) {
|
||||
new_row.setStringColumnValue(i, row.ith_column(i)->getStringValue());
|
||||
new_row.setStringColumnValue(i, row[i].getStringValue());
|
||||
} else if (m_col_defs[i].type == ColumnType::date_type) {
|
||||
new_row.setDateColumnValue(i, row.ith_column(i)->getDateValue());
|
||||
new_row.setDateColumnValue(i, row[i].getDateValue());
|
||||
} else if (m_col_defs[i].type == ColumnType::bool_type) {
|
||||
new_row.setBoolColumnValue(i, row.ith_column(i)->getBoolValue());
|
||||
new_row.setBoolColumnValue(i, row[i].getBoolValue());
|
||||
} else
|
||||
throw Exception("unsupported column type");
|
||||
}
|
||||
@@ -222,19 +222,19 @@ void Table::validate_column(const ColDefNode *col_def, ValueNode *col_val) {
|
||||
}
|
||||
}
|
||||
|
||||
void Table::validate_column(const ColDefNode *col_def, ColValue *col_val) {
|
||||
if (!col_def->null && col_val->isNull()) {
|
||||
void Table::validate_column(const ColDefNode *col_def, ColValue &col_val) {
|
||||
if (!col_def->null && col_val.isNull()) {
|
||||
throw Exception("Column " + col_def->name + " cannot be null");
|
||||
}
|
||||
if (col_def->type == ColumnType::varchar_type && !col_val->isNull() && col_val->getStringValue().size() > col_def->length) {
|
||||
throw Exception("Column value of " + col_def->name + " is too long (" + col_val->getStringValue() + ")");
|
||||
if (col_def->type == ColumnType::varchar_type && !col_val.isNull() && col_val.getStringValue().size() > col_def->length) {
|
||||
throw Exception("Column value of " + col_def->name + " is too long (" + col_val.getStringValue() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
void Table::validate_row(const Row &row) {
|
||||
for(int i = 0; i < m_col_defs.size(); i++) {
|
||||
ColDefNode col_def = m_col_defs[i];
|
||||
ColValue *col_val = row.ith_column(i);
|
||||
ColValue &col_val = row[i];
|
||||
|
||||
validate_column(&col_def, col_val);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user