fixed core- and orm-tests. postgres-tests needs some work

This commit is contained in:
Sascha Kühl
2025-11-20 15:35:40 +01:00
parent 95c555d03a
commit 3f3773dc71
17 changed files with 170 additions and 139 deletions
+1 -1
View File
@@ -151,7 +151,7 @@ private:
const sql::dialect &dialect_;
std::unique_ptr<object::repository> schema_;
mutable std::unordered_map<std::string, object::object_definition> prototypes_;
mutable std::unordered_map<std::string, std::vector<object::attribute_definition>> prototypes_;
};
template<typename Type>
+11 -15
View File
@@ -129,13 +129,12 @@ public:
access::process(*this , obj);
table_info_stack_.pop();
auto pk = info->get().definition().primary_key();
if (!pk) {
if (!info->get().has_primary_key()) {
throw query_builder_exception{query_build_error::MissingPrimaryKey};
}
append_join(
query::column{table_info_stack_.top().table, table_info_stack_.top().info.get().definition().primary_key()->name()},
query::column{table_info_stack_.top().table, table_info_stack_.top().info.get().reference_column()->name()},
query::column{next->second, join_column}
);
}
@@ -166,18 +165,17 @@ public:
access::process(*this , obj);
table_info_stack_.pop();
auto pk = info->get().definition().primary_key();
if (!pk) {
if (!info->get().has_primary_key()) {
throw query_builder_exception{query_build_error::MissingPrimaryKey};
}
append_join(
query::column{table_info_stack_.top().table, table_info_stack_.top().info.get().definition().primary_key()->name()},
query::column{table_info_stack_.top().table, table_info_stack_.top().info.get().reference_column()->name()},
query::column{relation->second, join_column}
);
append_join(
query::column{relation->second, inverse_join_column},
query::column{next->second, pk->name()}
query::column{next->second, info->get().reference_column()->name()}
);
}
@@ -206,20 +204,19 @@ public:
access::process(*this , obj);
table_info_stack_.pop();
auto pk = info->get().definition().primary_key();
if (!pk) {
if (!info->get().has_primary_key()) {
throw query_builder_exception{query_build_error::MissingPrimaryKey};
}
const auto join_columns = join_columns_collector_.collect<typename ContainerType::value_type::value_type>();
append_join(
query::column{table_info_stack_.top().table, table_info_stack_.top().info.get().definition().primary_key()->name()},
query::column{table_info_stack_.top().table, table_info_stack_.top().info.get().reference_column()->name()},
query::column{relation->second, join_columns.inverse_join_column}
);
append_join(
query::column{relation->second, join_columns.join_column},
query::column{next->second, pk->name()}
query::column{next->second, info->get().reference_column()->name()}
);
}
@@ -253,8 +250,7 @@ void session_query_builder::on_foreign_object(const char *id, Pointer &, const u
if (!info) {
throw query_builder_exception{query_build_error::UnknownType};
}
auto pk = info->get().definition().primary_key();
if (!pk) {
if (!info->get().has_primary_key()) {
throw query_builder_exception{query_build_error::MissingPrimaryKey};
}
@@ -273,7 +269,7 @@ void session_query_builder::on_foreign_object(const char *id, Pointer &, const u
append_join(
query::column{table_info_stack_.top().table, id},
query::column{next->second, pk->name()}
query::column{next->second, info->get().reference_column()->name()}
);
} else {
push(id);
@@ -282,7 +278,7 @@ void session_query_builder::on_foreign_object(const char *id, Pointer &, const u
// create select query
auto result = matador::query::query::select(generator::columns<typename Pointer::value_type>(schema_, generator::column_generator_options::ForceLazy))
.from(*foreign_table)
.where(column(foreign_table, pk->name(), "") == _)
.where(column(foreign_table, info->get().reference_column()->name(), "") == _)
.prepare(executor_);
if (!result) {
throw query_builder_exception(query_build_error::QueryError, result.release_error());