entity query and record progress

This commit is contained in:
2024-03-04 20:09:39 +01:00
parent 830185c3c5
commit be610ffcad
31 changed files with 294 additions and 50 deletions
@@ -33,14 +33,14 @@ public:
size_t execute(const std::string &stmt) override;
sql::record describe(const std::string& table) override;
std::vector<sql::column_definition> describe(const std::string& table) override;
bool exists(const std::string &schema_name, const std::string &table_name) override;
private:
struct fetch_context
{
sql::record prototype;
std::vector<sql::column_definition> prototype;
sqlite_result_reader::rows rows;
};
+4 -4
View File
@@ -65,7 +65,7 @@ int sqlite_connection::parse_result(void* param, int column_count, char** values
if (context->prototype.empty()) {
for(int i = 0; i < column_count; ++i) {
context->prototype.append(sql::column_definition{columns[i]});
context->prototype.emplace_back(columns[i]);
}
}
@@ -144,12 +144,12 @@ sql::data_type_t string2type(const char *type)
}
}
sql::record sqlite_connection::describe(const std::string& table)
std::vector<sql::column_definition> sqlite_connection::describe(const std::string& table)
{
const auto result = fetch_internal("PRAGMA table_info(" + table + ")");
sqlite_result_reader reader(result.rows, result.prototype.size());
sql::record prototype;
std::vector<sql::column_definition> prototype;
while (reader.fetch()) {
char *end = nullptr;
// Todo: add index to column
@@ -163,7 +163,7 @@ sql::record sqlite_connection::describe(const std::string& table)
null_opt = sql::null_option::NOT_NULL;
}
// f.default_value(res->column(4));
prototype.append({name, type, utils::null_attributes, null_opt, index});
prototype.emplace_back(name, type, utils::null_attributes, null_opt, index);
}
return std::move(prototype);