query builder progress

This commit is contained in:
Sascha Kühl
2025-12-03 16:18:03 +01:00
parent bfbbd4c589
commit 19eb54df8d
11 changed files with 360 additions and 192 deletions
+2 -4
View File
@@ -52,7 +52,7 @@ TEST_CASE_METHOD(QueryFixture, "Test create table sql statement string", "[query
.table("person")
.columns({
attribute("id", basic_type::type_uint32),
attribute("name", basic_type::type_varchar, 255),
attribute("name", basic_type::type_varchar, {255, constraints::Unique}),
attribute("age", basic_type::type_uint16),
attribute("address", basic_type::type_uint32)
})
@@ -62,9 +62,7 @@ TEST_CASE_METHOD(QueryFixture, "Test create table sql statement string", "[query
})
.compile(*db);
REQUIRE(ctx.sql == R"##(CREATE TABLE "person" ("id" BIGINT NOT NULL, "name" VARCHAR(255) NOT NULL UNIQUE, "age" INTEGER NOT NULL, "address" BIGINT NOT NULL, CONSTRAINT PK_person PRIMARY KEY (id)))##");
REQUIRE(ctx.additional_commands.size() == 1);
REQUIRE(ctx.additional_commands[0].sql == R"##(ALTER TABLE "person" ADD CONSTRAINT FK_person_address FOREIGN KEY ("address") REFERENCES address(id))##");
REQUIRE(ctx.sql == R"##(CREATE TABLE "person" ("id" BIGINT NOT NULL, "name" VARCHAR(255) NOT NULL UNIQUE, "age" INTEGER NOT NULL, "address" BIGINT NOT NULL, CONSTRAINT PK_person PRIMARY KEY (id), CONSTRAINT FK_person_address FOREIGN KEY (address)))##");
}
TEST_CASE_METHOD(QueryFixture, "Test drop table sql statement string", "[query]") {