blob progress

This commit is contained in:
Sascha Kühl
2024-01-23 16:09:59 +01:00
parent 9c8e402692
commit aa5d32e30c
8 changed files with 58 additions and 6 deletions
+25
View File
@@ -149,4 +149,29 @@ TEST_CASE("Select sql statement string with offset and limit", "[query]") {
REQUIRE(q.sql == R"(SELECT "id", "name", "age" FROM "person" OFFSET 10 LIMIT 20)");
REQUIRE(q.table_name == "person");
}
TEST_CASE("Create, insert and select a blob column", "[query][blob]") {
dialect d = dialect_builder::builder().create().build();
query_builder query(d);
auto q = query.create().table("person", {
make_pk_column<unsigned long>("id"),
make_column<std::string>("name", 255),
make_column<blob>("data")
}).compile();
REQUIRE(q.sql == R"##(CREATE TABLE "person" ("id" BIGINT NOT NULL, "name" VARCHAR(255) NOT NULL, "data" BLOB NOT NULL, CONSTRAINT PK_person PRIMARY KEY (id)))##");
REQUIRE(q.table_name == "person");
q = query.insert().into("person", {
"id", "name", "data"
}).values({7UL, "george", blob{1, 'A', 3, 4}}).compile();
REQUIRE(q.sql == R"(INSERT INTO "person" ("id", "name", "data") VALUES (7, 'george', X'01410304'))");
REQUIRE(q.table_name == "person");
q = query.select({"id", "name", "data"}).from("person").compile();
REQUIRE(q.sql == R"(SELECT "id", "name", "data" FROM "person")");
REQUIRE(q.table_name == "person");
}