fixed core- and orm-tests. postgres-tests needs some work
This commit is contained in:
@@ -57,7 +57,7 @@ matador::utils::result<void, matador::utils::error> matador::orm::schema::create
|
||||
// std::cout << result.sql << std::endl;
|
||||
for (const auto &node: repo_) {
|
||||
auto ctx = query::query::create()
|
||||
.table(node->name(), node->info().definition()->columns())
|
||||
.table(node->name(), node->info().attributes())
|
||||
.compile(*c);
|
||||
|
||||
for ( const auto& [sql, command] : ctx.additional_commands ) {
|
||||
|
||||
@@ -52,7 +52,7 @@ utils::result<void, utils::error> session::create_schema() const {
|
||||
auto c = cache_.pool().acquire();
|
||||
for (const auto &node: *schema_) {
|
||||
auto ctx = query::query::create()
|
||||
.table(node->name(), node->info().definition()->columns())
|
||||
.table(node->name(), node->info().attributes())
|
||||
.compile(*c);
|
||||
|
||||
for ( const auto& [sql, command] : ctx.additional_commands ) {
|
||||
@@ -100,7 +100,9 @@ utils::result<sql::query_result<sql::record>, utils::error> session::fetch_all(c
|
||||
}
|
||||
// adjust columns from given query
|
||||
for (auto &col: q.prototype) {
|
||||
if (const auto rit = it->second.find(col.name()); rit != it->second.end()) {
|
||||
if (const auto rit = std::find_if(it->second.begin(), it->second.end(), [&col](const auto &value) {
|
||||
return value.name() == col.name();
|
||||
}); rit != it->second.end()) {
|
||||
const_cast<object::attribute_definition &>(col).change_type(rit->type());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,14 +138,14 @@ void query_compiler::visit(internal::query_select_part &part)
|
||||
}
|
||||
|
||||
void query_compiler::visit(internal::query_from_part &part) {
|
||||
query_.table_name = part.table().alias();
|
||||
query_.sql += " " + build_table_name(part.token(), *dialect_, query_.table_name);
|
||||
query_.table_name = part.table().name();
|
||||
query_.sql += " " + build_table_name(part.token(), *dialect_, part.table());
|
||||
query_.table_aliases.insert({query_.table_name, part.table().alias()});
|
||||
}
|
||||
|
||||
void query_compiler::visit(internal::query_join_part &part)
|
||||
{
|
||||
query_.sql += " " + query_compiler::build_table_name(part.token(), *dialect_, part.table());
|
||||
query_.sql += " " + build_table_name(part.token(), *dialect_, part.table());
|
||||
}
|
||||
|
||||
void query_compiler::visit(internal::query_on_part &part) {
|
||||
@@ -335,7 +335,7 @@ void query_compiler::visit(internal::query_create_table_part &part)
|
||||
fk_cmd += " CONSTRAINT FK_" + query_.table_name;
|
||||
fk_cmd += "_" + column;
|
||||
fk_cmd += " FOREIGN KEY (" + dialect_->prepare_identifier_string(column) + ")";
|
||||
fk_cmd += " REFERENCES " + reference_column->object()->name() + "(" + reference_column->name() + ")";
|
||||
fk_cmd += " REFERENCES " + reference_column->table_name() + "(" + reference_column->name() + ")";
|
||||
query_.additional_commands.push_back({fk_cmd, sql::sql_command::SQL_ALTER_TABLE});
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "matador/sql/interface/connection_impl.hpp"
|
||||
|
||||
#include "matador/utils/string.hpp"
|
||||
#include "matador/utils/value.hpp"
|
||||
|
||||
namespace matador::sql {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user