Row::ith_column() method removed
This commit is contained in:
22
usql.cpp
22
usql.cpp
@@ -205,7 +205,7 @@ std::unique_ptr<Table> USql::execute_select(SelectFromTableNode &node) {
|
||||
|
||||
new_row.setColumnValue(&result_tbl_col_defs[idx], col_value);
|
||||
} else {
|
||||
ColValue *col_value = row->ith_column(row_col_index);
|
||||
ColValue &col_value = row->operator[](row_col_index);
|
||||
new_row.setColumnValue(&result_tbl_col_defs[idx], col_value);
|
||||
}
|
||||
}
|
||||
@@ -240,10 +240,10 @@ void USql::execute_order_by(SelectFromTableNode &node, Table *table, Table *resu
|
||||
for(const auto& order_by_col_def : node.order_by) {
|
||||
// TODO validate index
|
||||
ColDefNode col_def = result->get_column_def(order_by_col_def.col_index - 1);
|
||||
ColValue *a_val = a.ith_column(col_def.order);
|
||||
ColValue *b_val = b.ith_column(col_def.order);
|
||||
ColValue &a_val = a[col_def.order];
|
||||
ColValue &b_val = b[col_def.order];
|
||||
|
||||
int compare = a_val->compare(b_val);
|
||||
int compare = a_val.compare(b_val);
|
||||
|
||||
if (compare < 0) return order_by_col_def.ascending;
|
||||
if (compare > 0) return !order_by_col_def.ascending;
|
||||
@@ -474,21 +474,21 @@ std::unique_ptr<ValueNode> USql::eval_value_node(Table *table, Row &row, Node *n
|
||||
std::unique_ptr<ValueNode> USql::eval_database_value_node(Table *table, Row &row, Node *node) {
|
||||
auto *dvl = static_cast<DatabaseValueNode *>(node);
|
||||
ColDefNode col_def = table->get_column_def( dvl->col_name); // TODO optimize it to just get this def once
|
||||
auto db_value = row.ith_column(col_def.order);
|
||||
ColValue &db_value = row[col_def.order];
|
||||
|
||||
if (db_value->isNull())
|
||||
if (db_value.isNull())
|
||||
return std::make_unique<NullValueNode>();
|
||||
|
||||
if (col_def.type == ColumnType::integer_type)
|
||||
return std::make_unique<IntValueNode>(db_value->getIntValue());
|
||||
return std::make_unique<IntValueNode>(db_value.getIntValue());
|
||||
if (col_def.type == ColumnType::float_type)
|
||||
return std::make_unique<DoubleValueNode>(db_value->getDoubleValue());
|
||||
return std::make_unique<DoubleValueNode>(db_value.getDoubleValue());
|
||||
if (col_def.type == ColumnType::varchar_type)
|
||||
return std::make_unique<StringValueNode>(db_value->getStringValue());
|
||||
return std::make_unique<StringValueNode>(db_value.getStringValue());
|
||||
if (col_def.type == ColumnType::bool_type)
|
||||
return std::make_unique<BooleanValueNode>(db_value->getBoolValue());
|
||||
return std::make_unique<BooleanValueNode>(db_value.getBoolValue());
|
||||
if (col_def.type == ColumnType::date_type)
|
||||
return std::make_unique<IntValueNode>(db_value->getIntValue());
|
||||
return std::make_unique<IntValueNode>(db_value.getIntValue());
|
||||
|
||||
throw Exception("unknown database value type");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user