some sql classes refactorings like column and table structs to classes
This commit is contained in:
@@ -52,6 +52,9 @@ matador::utils::result<void, matador::utils::error> matador::orm::schema::create
|
||||
|
||||
std::vector<std::string> fk_sql_commands;
|
||||
auto c = pool_.acquire();
|
||||
|
||||
// auto result = query::query::create().schema( repo_.name() ).compile( *c );
|
||||
// std::cout << result.sql << std::endl;
|
||||
for (const auto &node: repo_) {
|
||||
auto ctx = query::query::create()
|
||||
.table(node->name(), node->info().definition().columns())
|
||||
|
||||
@@ -90,13 +90,13 @@ utils::result<sql::query_result<sql::record>, utils::error> session::fetch_all(c
|
||||
if (!c.valid()) {
|
||||
return utils::failure(make_error(error_code::NoConnectionAvailable, "Failed to acquire connection."));
|
||||
}
|
||||
auto it = prototypes_.find(q.table.name);
|
||||
auto it = prototypes_.find(q.table.name());
|
||||
if (it == prototypes_.end()) {
|
||||
auto result = c->describe(q.table.name);
|
||||
auto result = c->describe(q.table.name());
|
||||
if (!result) {
|
||||
return utils::failure(result.err());
|
||||
}
|
||||
it = prototypes_.emplace(q.table.name, *result).first;
|
||||
it = prototypes_.emplace(q.table.name(), *result).first;
|
||||
}
|
||||
// adjust columns from given query
|
||||
for (auto &col: q.prototype) {
|
||||
|
||||
@@ -39,12 +39,12 @@ void criteria_transformer::visit( const query::not_criteria& node ) {
|
||||
}
|
||||
|
||||
void criteria_transformer::update_criteria_column(const query::abstract_column_criteria& node) const {
|
||||
const auto it = tables_by_name_.find(node.column().table()->name);
|
||||
const auto it = tables_by_name_.find(node.column().table()->name());
|
||||
if (it == tables_by_name_.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const_cast<sql::column&>(node.column()).table_ = it->second;
|
||||
const_cast<sql::column&>(node.column()).table(it->second);
|
||||
}
|
||||
|
||||
void session_query_builder::on_revision(const char *id, uint64_t &/*rev*/) {
|
||||
@@ -73,7 +73,7 @@ std::string session_query_builder::build_alias(const char prefix, const unsigned
|
||||
void session_query_builder::append_join(const sql::column &left, const sql::column &right) {
|
||||
using namespace matador::query;
|
||||
entity_query_data_.joins.push_back({
|
||||
{right.table_},
|
||||
{right.table()},
|
||||
std::make_unique<binary_column_criteria>(left, binary_operator::EQUALS, right)
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user