uses criteria for session::find methods

This commit is contained in:
Sascha Kühl
2025-10-30 14:54:39 +01:00
parent 44c50cf2af
commit 270c2922ff
23 changed files with 267 additions and 208 deletions
+9 -8
View File
@@ -26,6 +26,7 @@
using namespace matador::object;
using namespace matador::orm;
using namespace matador::query;
using namespace matador::utils;
using namespace matador::sql;
using namespace matador::test;
@@ -40,7 +41,7 @@ TEST_CASE("Create sql query data for entity with eager has one", "[query][entity
session_query_builder eqb(scm, db);
auto data = eqb.build<flight>(17U);
auto data = eqb.build<flight>("flights.id"_col == _);
REQUIRE(data.is_ok());
REQUIRE(data->root_table->name == "flights");
@@ -86,7 +87,7 @@ TEST_CASE("Create sql query data for entity with eager belongs to", "[query][ent
session_query_builder eqb(scm, db);
auto data = eqb.build<book>(17);
auto data = eqb.build<book>("books.id"_col == _);
REQUIRE(data.is_ok());
REQUIRE(data->root_table->name == "books");
@@ -114,9 +115,9 @@ TEST_CASE("Create sql query data for entity with eager belongs to", "[query][ent
query_context qc;
size_t index{0};
criteria_evaluator evaluator(db.dialect(), qc);
for (const auto &jd : data->joins) {
REQUIRE(jd.join_table->name == expected_join_data[index].first);
REQUIRE(evaluator.evaluate(*jd.condition) == expected_join_data[index].second);
for (const auto & [join_table, clause] : data->joins) {
REQUIRE(join_table->name == expected_join_data[index].first);
REQUIRE(evaluator.evaluate(*clause) == expected_join_data[index].second);
++index;
}
@@ -150,7 +151,7 @@ TEST_CASE("Create sql query data for entity with eager has many belongs to", "[q
session_query_builder eqb(scm, db);
auto data = eqb.build<order>(17);
auto data = eqb.build<order>("orders.order_id"_col == _);
REQUIRE(data.is_ok());
REQUIRE(data->root_table->name == "orders");
@@ -206,7 +207,7 @@ TEST_CASE("Create sql query data for entity with eager many to many", "[query][e
session_query_builder eqb(scm, db);
auto data = eqb.build<ingredient>(17);
auto data = eqb.build<ingredient>("ingredients.id"_col == _);
REQUIRE(data.is_ok());
REQUIRE(data->root_table->name == "ingredients");
@@ -252,7 +253,7 @@ TEST_CASE("Create sql query data for entity with eager many to many (inverse par
session_query_builder eqb(scm, db);
auto data = eqb.build<course>(17);
auto data = eqb.build<course>("courses.id"_col == _);
REQUIRE(data.is_ok());
REQUIRE(data->root_table->name == "courses");