some sql classes refactorings like column and table structs to classes
This commit is contained in:
@@ -44,7 +44,7 @@ TEST_CASE("Create sql query data for entity with eager has one", "[query][entity
|
||||
auto data = eqb.build<flight>("flights.id"_col == _);
|
||||
|
||||
REQUIRE(data.is_ok());
|
||||
REQUIRE(data->root_table->name == "flights");
|
||||
REQUIRE(data->root_table->name() == "flights");
|
||||
REQUIRE(data->joins.size() == 1);
|
||||
const std::vector<column> expected_columns {
|
||||
{ "flights", "id", "c01" },
|
||||
@@ -66,7 +66,7 @@ TEST_CASE("Create sql query data for entity with eager has one", "[query][entity
|
||||
size_t index{0};
|
||||
criteria_evaluator evaluator(db.dialect(), qc);
|
||||
for (const auto &[join_table, condition] : data->joins) {
|
||||
REQUIRE(join_table->name == expected_join_data[index].first);
|
||||
REQUIRE(join_table->name() == expected_join_data[index].first);
|
||||
REQUIRE(evaluator.evaluate(*condition) == expected_join_data[index].second);
|
||||
++index;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ TEST_CASE("Create sql query data for entity with eager belongs to", "[query][ent
|
||||
auto data = eqb.build<book>("books.id"_col == _);
|
||||
|
||||
REQUIRE(data.is_ok());
|
||||
REQUIRE(data->root_table->name == "books");
|
||||
REQUIRE(data->root_table->name() == "books");
|
||||
REQUIRE(data->joins.size() == 1);
|
||||
const std::vector<column> expected_columns {
|
||||
{ "books", "id", "c01" },
|
||||
@@ -116,7 +116,7 @@ TEST_CASE("Create sql query data for entity with eager belongs to", "[query][ent
|
||||
size_t index{0};
|
||||
criteria_evaluator evaluator(db.dialect(), qc);
|
||||
for (const auto & [join_table, clause] : data->joins) {
|
||||
REQUIRE(join_table->name == expected_join_data[index].first);
|
||||
REQUIRE(join_table->name() == expected_join_data[index].first);
|
||||
REQUIRE(evaluator.evaluate(*clause) == expected_join_data[index].second);
|
||||
++index;
|
||||
}
|
||||
@@ -126,7 +126,7 @@ TEST_CASE("Create sql query data for entity with eager belongs to", "[query][ent
|
||||
REQUIRE(cond == R"("t01"."id" = ?)");
|
||||
|
||||
auto q = matador::query::query::select(data->columns)
|
||||
.from(data->root_table->name);
|
||||
.from(data->root_table->name());
|
||||
|
||||
for (auto &jd : data->joins) {
|
||||
q.join_left(*jd.join_table)
|
||||
@@ -154,7 +154,7 @@ TEST_CASE("Create sql query data for entity with eager has many belongs to", "[q
|
||||
auto data = eqb.build<order>("orders.order_id"_col == _);
|
||||
|
||||
REQUIRE(data.is_ok());
|
||||
REQUIRE(data->root_table->name == "orders");
|
||||
REQUIRE(data->root_table->name() == "orders");
|
||||
REQUIRE(data->joins.size() == 1);
|
||||
const std::vector<column> expected_columns = {
|
||||
{ "orders", "order_id", "c01" },
|
||||
@@ -186,7 +186,7 @@ TEST_CASE("Create sql query data for entity with eager has many belongs to", "[q
|
||||
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(jd.join_table->name() == expected_join_data[index].first);
|
||||
REQUIRE(evaluator.evaluate(*jd.condition) == expected_join_data[index].second);
|
||||
++index;
|
||||
}
|
||||
@@ -210,7 +210,7 @@ TEST_CASE("Create sql query data for entity with eager many to many", "[query][e
|
||||
auto data = eqb.build<ingredient>("ingredients.id"_col == _);
|
||||
|
||||
REQUIRE(data.is_ok());
|
||||
REQUIRE(data->root_table->name == "ingredients");
|
||||
REQUIRE(data->root_table->name() == "ingredients");
|
||||
REQUIRE(data->joins.size() == 2);
|
||||
const std::vector<column> expected_columns {
|
||||
{ "ingredients", "id", "c01" },
|
||||
@@ -232,7 +232,7 @@ TEST_CASE("Create sql query data for entity with eager many to many", "[query][e
|
||||
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(jd.join_table->name() == expected_join_data[index].first);
|
||||
REQUIRE(evaluator.evaluate(*jd.condition) == expected_join_data[index].second);
|
||||
++index;
|
||||
}
|
||||
@@ -256,7 +256,7 @@ TEST_CASE("Create sql query data for entity with eager many to many (inverse par
|
||||
auto data = eqb.build<course>("courses.id"_col == _);
|
||||
|
||||
REQUIRE(data.is_ok());
|
||||
REQUIRE(data->root_table->name == "courses");
|
||||
REQUIRE(data->root_table->name() == "courses");
|
||||
REQUIRE(data->joins.size() == 2);
|
||||
const std::vector<column> expected_columns {
|
||||
{ "courses", "id", "c01" },
|
||||
@@ -278,7 +278,7 @@ TEST_CASE("Create sql query data for entity with eager many to many (inverse par
|
||||
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(jd.join_table->name() == expected_join_data[index].first);
|
||||
REQUIRE(evaluator.evaluate(*jd.condition) == expected_join_data[index].second);
|
||||
++index;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ protected:
|
||||
TEST_CASE_METHOD(CriteriaFixture, "Test binary criteria", "[criteria][binary]") {
|
||||
const auto name_col = "name"_col;
|
||||
|
||||
REQUIRE(name_col.name == "name");
|
||||
REQUIRE(name_col.column_name() == "name");
|
||||
|
||||
auto clause = name_col != "george";
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ TEST_CASE("Generate columns from object", "[column][generator]") {
|
||||
REQUIRE(columns.size() == expected_columns.size());
|
||||
|
||||
for (size_t i = 0; i != expected_columns.size(); ++i) {
|
||||
REQUIRE(expected_columns[i] == columns[i].name);
|
||||
REQUIRE(expected_columns[i] == columns[i].column_name());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user