entity query and record progress
This commit is contained in:
@@ -181,13 +181,13 @@ std::unique_ptr<sql::query_result_impl> mysql_connection::fetch(const std::strin
|
||||
|
||||
auto field_count = mysql_num_fields(result);
|
||||
auto fields = mysql_fetch_fields(result);
|
||||
sql::record prototype;
|
||||
std::vector<sql::column_definition> prototype;
|
||||
for (unsigned i = 0; i < field_count; ++i) {
|
||||
auto type = to_type(fields[i].type, fields[i].flags);
|
||||
auto options = to_constraints(fields[i].flags);
|
||||
auto null_opt = to_null_option(fields[i].flags);
|
||||
|
||||
prototype.append({fields[i].name, type, options, null_opt});
|
||||
prototype.emplace_back(fields[i].name, type, options, null_opt);
|
||||
}
|
||||
|
||||
return std::move(std::make_unique<sql::query_result_impl>(std::make_unique<mysql_result_reader>(result, field_count), std::move(prototype)));
|
||||
@@ -216,7 +216,7 @@ size_t mysql_connection::execute(const std::string &stmt)
|
||||
return mysql_affected_rows(mysql_.get());
|
||||
}
|
||||
|
||||
sql::record mysql_connection::describe(const std::string &table)
|
||||
std::vector<sql::column_definition> mysql_connection::describe(const std::string &table)
|
||||
{
|
||||
std::string stmt("SHOW COLUMNS FROM " + table);
|
||||
|
||||
@@ -230,7 +230,7 @@ sql::record mysql_connection::describe(const std::string &table)
|
||||
}
|
||||
|
||||
mysql_result_reader reader(result, mysql_num_fields(result));
|
||||
sql::record prototype;
|
||||
std::vector<sql::column_definition> prototype;
|
||||
while (reader.fetch()) {
|
||||
|
||||
char *end = nullptr;
|
||||
@@ -242,7 +242,7 @@ sql::record mysql_connection::describe(const std::string &table)
|
||||
if (strtoul(reader.column(2), &end, 10) == 0) {
|
||||
null_opt = sql::null_option::NOT_NULL;
|
||||
}
|
||||
prototype.append({name, typeinfo.type, {typeinfo.size}, null_opt, prototype.size()});
|
||||
prototype.push_back({name, typeinfo.type, {typeinfo.size}, null_opt, prototype.size()});
|
||||
}
|
||||
|
||||
return prototype;
|
||||
|
||||
Reference in New Issue
Block a user