added any type visitor and converter

This commit is contained in:
2023-11-21 20:07:07 +01:00
parent 171e8d36ce
commit 145c4dc0a3
28 changed files with 730 additions and 163 deletions
@@ -33,6 +33,8 @@ public:
sql::record describe(const std::string& table) override;
bool exists(const std::string &table_name) override;
private:
static int parse_result(void* param, int column_count, char** values, char** columns);
+15 -2
View File
@@ -153,14 +153,27 @@ sql::record sqlite_connection::describe(const std::string& table)
options = utils::constraints::NOT_NULL;
}
// f.default_value(res->column(4));
// end = nullptr;
// f.is_primary_key(strtoul(res->column(3), &end, 10) == 0);
prototype.append({name, type, {options}});
}
return std::move(prototype);
}
bool sqlite_connection::exists(const std::string &table_name)
{
const auto result = fetch("SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND tbl_name='" + table_name + "' LIMIT 1");
if (!result->fetch()) {
// Todo: throw an exception?
return false;
}
int v{};
result->read_value(nullptr, 0, v);
return v == 1;
}
}
extern "C"