fixed compilation

This commit is contained in:
Sascha Kühl
2025-12-16 16:21:09 +01:00
parent 4a19322ef8
commit 9eec5b64fb
10 changed files with 98 additions and 88 deletions
+48 -48
View File
@@ -46,14 +46,14 @@ TEST_CASE("Create sql query data for entity with eager has one", "[query][entity
REQUIRE(data.is_ok());
REQUIRE(data->root_table->name() == "flights");
REQUIRE(data->joins.size() == 1);
const auto flights = std::make_shared<table>("flights");
const auto airplanes = std::make_shared<table>("airplanes");
const auto flights = table("flights");
const auto airplanes = table("airplanes");
const std::vector<column> expected_columns {
{ flights, "id", "c01" },
{ airplanes, "id", "c02" },
{ airplanes, "brand", "c03" },
{ airplanes, "model", "c04" },
{ flights, "pilot_name", "c05" },
{ &flights, "id", "c01" },
{ &airplanes, "id", "c02" },
{ &airplanes, "brand", "c03" },
{ &airplanes, "model", "c04" },
{ &flights, "pilot_name", "c05" },
};
REQUIRE(data->columns.size() == expected_columns.size());
for (size_t i = 0; i != expected_columns.size(); ++i) {
@@ -94,18 +94,18 @@ TEST_CASE("Create sql query data for entity with eager belongs to", "[query][ent
REQUIRE(data.is_ok());
REQUIRE(data->root_table->name() == "books");
REQUIRE(data->joins.size() == 1);
const auto books = std::make_shared<table>("books");
const auto authors = std::make_shared<table>("authors");
const auto books = table("books");
const auto authors = table("authors");
const std::vector<column> expected_columns {
{ books, "id", "c01" },
{ books, "title", "c02" },
{ authors, "id", "c03" },
{ authors, "first_name", "c04" },
{ authors, "last_name", "c05" },
{ authors, "date_of_birth", "c06" },
{ authors, "year_of_birth", "c07" },
{ authors, "distinguished", "c08" },
{ books, "published_in", "c09" }
{ &books, "id", "c01" },
{ &books, "title", "c02" },
{ &authors, "id", "c03" },
{ &authors, "first_name", "c04" },
{ &authors, "last_name", "c05" },
{ &authors, "date_of_birth", "c06" },
{ &authors, "year_of_birth", "c07" },
{ &authors, "distinguished", "c08" },
{ &books, "published_in", "c09" }
};
REQUIRE(data->columns.size() == expected_columns.size());
for (size_t i = 0; i != expected_columns.size(); ++i) {
@@ -160,24 +160,24 @@ TEST_CASE("Create sql query data for entity with eager has many belongs to", "[q
REQUIRE(data.is_ok());
REQUIRE(data->root_table->name() == "orders");
REQUIRE(data->joins.size() == 1);
const auto orders = std::make_shared<table>("orders");
const auto order_details = std::make_shared<table>("order_details");
const auto orders = table("orders");
const auto order_details = table("order_details");
const std::vector<column> expected_columns = {
{ orders, "order_id", "c01" },
{ orders, "order_date", "c02" },
{ orders, "required_date", "c03" },
{ orders, "shipped_date", "c04" },
{ orders, "ship_via", "c05" },
{ orders, "freight", "c06" },
{ orders, "ship_name", "c07" },
{ orders, "ship_address", "c08" },
{ orders, "ship_city", "c09" },
{ orders, "ship_region", "c10" },
{ orders, "ship_postal_code", "c11" },
{ orders, "ship_country", "c12" },
{ order_details, "order_details_id", "c13" },
{ order_details, "order_id", "c14" },
{ order_details, "product_id", "c15" }
{ &orders, "order_id", "c01" },
{ &orders, "order_date", "c02" },
{ &orders, "required_date", "c03" },
{ &orders, "shipped_date", "c04" },
{ &orders, "ship_via", "c05" },
{ &orders, "freight", "c06" },
{ &orders, "ship_name", "c07" },
{ &orders, "ship_address", "c08" },
{ &orders, "ship_city", "c09" },
{ &orders, "ship_region", "c10" },
{ &orders, "ship_postal_code", "c11" },
{ &orders, "ship_country", "c12" },
{ &order_details, "order_details_id", "c13" },
{ &order_details, "order_id", "c14" },
{ &order_details, "product_id", "c15" }
};
REQUIRE(data->columns.size() == expected_columns.size());
for (size_t i = 0; i != expected_columns.size(); ++i) {
@@ -218,13 +218,13 @@ TEST_CASE("Create sql query data for entity with eager many to many", "[query][e
REQUIRE(data.is_ok());
REQUIRE(data->root_table->name() == "ingredients");
REQUIRE(data->joins.size() == 2);
const auto ingredients = std::make_shared<table>("ingredients");
const auto recipes = std::make_shared<table>("recipes");
const auto ingredients = table("ingredients");
const auto recipes = table("recipes");
const std::vector<column> expected_columns {
{ ingredients, "id", "c01" },
{ ingredients, "name", "c02" },
{ recipes, "id", "c03" },
{ recipes, "name", "c04" }
{ &ingredients, "id", "c01" },
{ &ingredients, "name", "c02" },
{ &recipes, "id", "c03" },
{ &recipes, "name", "c04" }
};
REQUIRE(data->columns.size() == expected_columns.size());
for (size_t i = 0; i != expected_columns.size(); ++i) {
@@ -266,13 +266,13 @@ TEST_CASE("Create sql query data for entity with eager many to many (inverse par
REQUIRE(data.is_ok());
REQUIRE(data->root_table->name() == "courses");
REQUIRE(data->joins.size() == 2);
const auto courses = std::make_shared<table>("courses");
const auto students = std::make_shared<table>("students");
const auto courses = table("courses");
const auto students = table("students");
const std::vector<column> expected_columns {
{ courses, "id", "c01" },
{ courses, "title", "c02" },
{ students, "id", "c03" },
{ students, "name", "c04" }
{ &courses, "id", "c01" },
{ &courses, "title", "c02" },
{ &students, "id", "c03" },
{ &students, "name", "c04" }
};
REQUIRE(data->columns.size() == expected_columns.size());
for (size_t i = 0; i != expected_columns.size(); ++i) {
@@ -315,7 +315,7 @@ TEST_CASE("Test eager relationship", "[session][eager]") {
.from(*data->root_table)
.join_left(data->joins)
.where(std::move(data->where_clause))
.order_by(column{data->root_table, data->pk_column_name})
.order_by(column{data->root_table.get(), data->pk_column_name})
.asc()
.str(db);