schema progress (does not compile)
This commit is contained in:
@@ -32,18 +32,18 @@ TEST_CASE("Test column value generator", "[generator][column_value]") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Test column generator", "[generator][column]") {
|
||||
SECTION("Test column generator for simple table") {
|
||||
const std::vector expected_columns {
|
||||
column("id"),
|
||||
column("brand"),
|
||||
column("model"),
|
||||
};
|
||||
const auto result = generator::columns<airplane>();
|
||||
REQUIRE(result.size() == expected_columns.size());
|
||||
auto it = result.begin();
|
||||
for (const auto& c : expected_columns) {
|
||||
REQUIRE(c.equals( *it++));
|
||||
}
|
||||
}
|
||||
}
|
||||
// TEST_CASE("Test column generator", "[generator][column]") {
|
||||
// SECTION("Test column generator for simple table") {
|
||||
// const std::vector expected_columns {
|
||||
// column("id"),
|
||||
// column("brand"),
|
||||
// column("model"),
|
||||
// };
|
||||
// const auto result = generator::columns<airplane>();
|
||||
// REQUIRE(result.size() == expected_columns.size());
|
||||
// auto it = result.begin();
|
||||
// for (const auto& c : expected_columns) {
|
||||
// REQUIRE(c.equals( *it++));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -39,9 +39,9 @@ TEST_CASE_METHOD(QueryFixture, "Test create table sql statement string", "[query
|
||||
auto result = query::create()
|
||||
.table({"person"})
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("name", basic_type::Varchar, 255),
|
||||
attribute("age", basic_type::UInt16)
|
||||
column("id", basic_type::UInt32),
|
||||
column("name", basic_type::Varchar, 255),
|
||||
column("age", basic_type::UInt16)
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_person").primary_key({"id"})
|
||||
@@ -53,10 +53,10 @@ TEST_CASE_METHOD(QueryFixture, "Test create table sql statement string", "[query
|
||||
auto ctx = query::create()
|
||||
.table("person")
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("name", basic_type::Varchar, {255, constraints::Unique}),
|
||||
attribute("age", basic_type::UInt16),
|
||||
attribute("address", basic_type::UInt32)
|
||||
column("id", basic_type::UInt32),
|
||||
column("name", basic_type::Varchar, 255).unique(),
|
||||
column("age", basic_type::UInt16),
|
||||
column("address", basic_type::UInt32)
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_person").primary_key({"id"}),
|
||||
@@ -221,9 +221,9 @@ TEST_CASE_METHOD(QueryFixture, "Test create, insert and select a blob column", "
|
||||
auto result = query::create()
|
||||
.table("person")
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("name", basic_type::Varchar, 255),
|
||||
attribute("data", basic_type::Blob)
|
||||
column("id", basic_type::UInt32),
|
||||
column("name", basic_type::Varchar, 255),
|
||||
column("data", basic_type::Blob)
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_person").primary_key({"id"})
|
||||
@@ -247,10 +247,14 @@ TEST_CASE_METHOD(QueryFixture, "Test create, insert and select a blob column", "
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(QueryFixture, "Test select statement with join_left", "[query][statement][join_left]") {
|
||||
const auto ap = table("airplane").as("ap");
|
||||
const auto f = table("flight").as("f");
|
||||
const class matador::query::column col1 = {&f, "airplane_id"};
|
||||
const class matador::query::column col2 = {&ap, "id"};
|
||||
const auto result = query::select({"f.id", "ap.brand", "f.pilot_name"})
|
||||
.from({"flight", "f"})
|
||||
.join_left({"airplane", "ap"})
|
||||
.on("f.airplane_id"_col == "ap.id"_col)
|
||||
.from(table{"flight"}.as("f"))
|
||||
.join_left(table{"airplane"}.as("ap"))
|
||||
.on(col1 == col2)
|
||||
.str(*db);
|
||||
|
||||
REQUIRE(result == R"(SELECT "f"."id", "ap"."brand", "f"."pilot_name" FROM "flight" "f" LEFT JOIN "airplane" "ap" ON "f"."airplane_id" = "ap"."id")");
|
||||
|
||||
Reference in New Issue
Block a user