changed the interface of on_primary_key to have a third parameter of type primary_key_attribute
This commit is contained in:
@@ -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]") {
|
||||
|
||||
Reference in New Issue
Block a user