renamed column to table_column and constraint to table_constraint.
This commit is contained in:
+25
-21
@@ -156,7 +156,7 @@ TEST_CASE_METHOD(QueryFixture, "Select statement with foreign key", "[query][for
|
||||
.and_then( [this] { return repo.attach<flight>("flight");} );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
auto obj = object_generator::generate<airplane>(repo, "airplane");
|
||||
auto obj = object_generator::generate<airplane>(repo.repo(), "airplane");
|
||||
auto res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
@@ -168,7 +168,7 @@ TEST_CASE_METHOD(QueryFixture, "Select statement with foreign key", "[query][for
|
||||
REQUIRE(db.exists("airplane"));
|
||||
tables_to_drop.emplace("airplane");
|
||||
|
||||
obj = object_generator::generate<flight>(repo, "flight");
|
||||
obj = object_generator::generate<flight>(repo.repo(), "flight");
|
||||
res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
@@ -225,7 +225,7 @@ TEST_CASE_METHOD(QueryFixture, "Select statement with foreign key and join_left"
|
||||
.and_then( [this] { return repo.attach<flight>("flight");} );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
auto obj = object_generator::generate<airplane>(repo, "airplane");
|
||||
auto obj = object_generator::generate<airplane>(repo.repo(), "airplane");
|
||||
auto res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
@@ -237,7 +237,7 @@ TEST_CASE_METHOD(QueryFixture, "Select statement with foreign key and join_left"
|
||||
REQUIRE(db.exists("airplane"));
|
||||
tables_to_drop.emplace("airplane");
|
||||
|
||||
obj = object_generator::generate<flight>(repo, "flight");
|
||||
obj = object_generator::generate<flight>(repo.repo(), "flight");
|
||||
res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
@@ -295,8 +295,8 @@ TEST_CASE_METHOD(QueryFixture, "Select statement with foreign key and join_left"
|
||||
REQUIRE(f.value()->at(2).as<std::string>() == "hans");
|
||||
|
||||
auto select_result = query::select({"f.id", "ap.brand", "ap.model", "f.pilot_name"})
|
||||
.from({"flight", "f"})
|
||||
.join_left({"airplane", "ap"})
|
||||
.from("flight"_tab.as("f"))
|
||||
.join_left("airplane"_tab.as("ap"))
|
||||
.on("f.airplane_id"_col == "ap.id"_col)
|
||||
.order_by("f.id").asc()
|
||||
.fetch_all(db);
|
||||
@@ -321,7 +321,7 @@ TEST_CASE_METHOD(QueryFixture, "Select statement with foreign key and for single
|
||||
.and_then( [this] { return repo.attach<flight>("flight");} );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
auto obj = object_generator::generate<airplane>(repo, "airplane");
|
||||
auto obj = object_generator::generate<airplane>(repo.repo(), "airplane");
|
||||
auto res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
@@ -333,7 +333,7 @@ TEST_CASE_METHOD(QueryFixture, "Select statement with foreign key and for single
|
||||
REQUIRE(db.exists("airplane"));
|
||||
tables_to_drop.emplace("airplane");
|
||||
|
||||
obj = object_generator::generate<flight>(repo, "flight");
|
||||
obj = object_generator::generate<flight>(repo.repo(), "flight");
|
||||
res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
@@ -393,8 +393,8 @@ TEST_CASE_METHOD(QueryFixture, "Select statement with foreign key and for single
|
||||
REQUIRE(f.value()->at(2).as<std::string>() == "hans");
|
||||
|
||||
auto select_result = query::select({"f.id", "f.airplane_id", "ap.brand", "ap.model", "f.pilot_name"})
|
||||
.from({"flight", "f"})
|
||||
.join_left({"airplane", "ap"})
|
||||
.from("flight"_tab.as("f"))
|
||||
.join_left("airplane"_tab.as("ap"))
|
||||
.on("f.airplane_id"_col == "ap.id"_col)
|
||||
.where("f.id"_col == 4)
|
||||
.fetch_one<flight>(db);
|
||||
@@ -416,7 +416,7 @@ TEST_CASE_METHOD(QueryFixture, "Select statement with many to many relationship"
|
||||
auto result = repo.attach<recipe>("recipes")
|
||||
.and_then( [this] { return repo.attach<ingredient>("ingredients"); } );
|
||||
|
||||
auto obj = object_generator::generate<recipe>(repo, "recipes");
|
||||
auto obj = object_generator::generate<recipe>(repo.repo(), "recipes");
|
||||
auto res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
@@ -428,7 +428,7 @@ TEST_CASE_METHOD(QueryFixture, "Select statement with many to many relationship"
|
||||
REQUIRE(db.exists("recipes"));
|
||||
tables_to_drop.emplace("recipes");
|
||||
|
||||
obj = object_generator::generate<ingredient>(repo, "ingredients");
|
||||
obj = object_generator::generate<ingredient>(repo.repo(), "ingredients");
|
||||
res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
@@ -440,7 +440,7 @@ TEST_CASE_METHOD(QueryFixture, "Select statement with many to many relationship"
|
||||
REQUIRE(db.exists("ingredients"));
|
||||
tables_to_drop.emplace("ingredients");
|
||||
|
||||
obj = object_generator::generate<recipe_ingredient>(repo, "recipe_ingredients");
|
||||
obj = object_generator::generate<recipe_ingredient>(repo.repo(), "recipe_ingredients");
|
||||
res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
@@ -507,8 +507,8 @@ TEST_CASE_METHOD(QueryFixture, "Select statement with many to many relationship"
|
||||
}
|
||||
|
||||
auto select_result = query::select({"r.id", "r.name", "ri.ingredient_id"})
|
||||
.from({"recipes", "r"})
|
||||
.join_left({"recipe_ingredients", "ri"})
|
||||
.from("recipes"_tab.as("r"))
|
||||
.join_left("recipe_ingredients"_tab.as("ri"))
|
||||
.on("r.id"_col == "ri.recipe_id"_col)
|
||||
.fetch_all(db);
|
||||
REQUIRE(select_result.is_ok());
|
||||
@@ -533,9 +533,11 @@ TEST_CASE_METHOD(QueryFixture, "Select statement with many to many relationship"
|
||||
}
|
||||
|
||||
select_result = query::select({"r.id", "r.name", "ri.ingredient_id", "i.name"})
|
||||
.from({"recipes", "r"})
|
||||
.join_left({"recipe_ingredients", "ri"}).on("r.id"_col == "ri.recipe_id"_col)
|
||||
.join_left({"ingredients", "i"}).on("ri.ingredient_id"_col == "i.id"_col)
|
||||
.from("recipes"_tab.as("r"))
|
||||
.join_left("recipe_ingredients"_tab.as("ri"))
|
||||
.on("r.id"_col == "ri.recipe_id"_col)
|
||||
.join_left("ingredients"_tab.as("i"))
|
||||
.on("ri.ingredient_id"_col == "i.id"_col)
|
||||
.fetch_all(db);
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
@@ -560,9 +562,11 @@ TEST_CASE_METHOD(QueryFixture, "Select statement with many to many relationship"
|
||||
}
|
||||
|
||||
select_result = query::select({"r.id", "r.name", "ri.ingredient_id", "i.name"})
|
||||
.from({"recipes", "r"})
|
||||
.join_left({"recipe_ingredients", "ri"}).on("r.id"_col == "ri.recipe_id"_col)
|
||||
.join_left({"ingredients", "i"}).on("ri.ingredient_id"_col == "i.id"_col)
|
||||
.from("recipes"_tab.as("r"))
|
||||
.join_left("recipe_ingredients"_tab.as("ri"))
|
||||
.on("r.id"_col == "ri.recipe_id"_col)
|
||||
.join_left("ingredients"_tab.as("i"))
|
||||
.on("ri.ingredient_id"_col == "i.id"_col)
|
||||
.where("r.id"_col == 8)
|
||||
.fetch_all(db);
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
Reference in New Issue
Block a user