usql update
This commit is contained in:
17
ml_usql.cpp
17
ml_usql.cpp
@@ -13,20 +13,25 @@ MlValue uSQL::ivaluize(const usql::Table *table) {
|
||||
std::vector<MlValue> rows;
|
||||
std::vector<MlValue> columns;
|
||||
|
||||
columns.reserve(table->columns_count());
|
||||
rows.reserve(table->rows_count());
|
||||
|
||||
for (auto row : table->m_rows) {
|
||||
columns.clear();
|
||||
for (int i = 0; i < table->columns_count(); i++) {
|
||||
auto c = row.ith_column(i);
|
||||
auto & c = row[i];
|
||||
auto type = table->m_col_defs[i].type;
|
||||
if (type == ColumnType::integer_type) {
|
||||
columns.push_back(MlValue(c->getIntValue()));
|
||||
if (type == ColumnType::integer_type || type == ColumnType::date_type) {
|
||||
columns.push_back(MlValue(c.getIntValue()));
|
||||
} else if (type == ColumnType::bool_type) {
|
||||
columns.push_back(c.getBoolValue() ? MlValue(c.getIntValue()) : MlValue::nil());
|
||||
} else if (type == ColumnType::float_type) {
|
||||
columns.push_back(MlValue(c->getDoubleValue()));
|
||||
columns.push_back(MlValue(c.getDoubleValue()));
|
||||
} else {
|
||||
columns.push_back(MlValue::string(c->getStringValue()));
|
||||
columns.push_back(MlValue::string(c.getStringValue()));
|
||||
}
|
||||
}
|
||||
rows.push_back(columns);
|
||||
rows.emplace_back(columns);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user