changed the interface of on_primary_key to have a third parameter of type primary_key_attribute

This commit is contained in:
Sascha Kühl
2025-07-18 12:08:21 +02:00
parent d8e43c1f95
commit 7b5123df16
38 changed files with 274 additions and 392 deletions
+5 -6
View File
@@ -12,9 +12,6 @@
#include "matador/utils/placeholder.hpp"
// #include "models/author.hpp"
// #include "models/book.hpp"
using namespace matador::test;
using namespace matador::object;
using namespace matador::sql;
@@ -31,15 +28,17 @@ TEST_CASE_METHOD(QueryFixture, "Test create table sql statement string", "[query
REQUIRE(result == R"##(CREATE TABLE "person" ("id" BIGINT NOT NULL, "name" VARCHAR(255) NOT NULL, "age" INTEGER NOT NULL, CONSTRAINT PK_person PRIMARY KEY (id)))##");
result = query::create()
auto ctx = query::create()
.table("person", {
make_pk_column<uint32_t>("id"),
make_column<std::string>("name", {255, constraints::UNIQUE}, null_option::NOT_NULL),
make_column<unsigned short>("age"),
make_fk_column<uint32_t>("address", "address", "id")
}).str(*db);
}).compile(*db);
REQUIRE(result == 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) 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)))##");
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))##");
}
TEST_CASE_METHOD(QueryFixture, "Test drop table sql statement string", "[query]") {