Compare commits
No commits in common. "98da0884f159b981dacafa49815673c61bdd59ab" and "980cabe94f92fd40d85e340f93e1fb8556f60cca" have entirely different histories.
98da0884f1
...
980cabe94f
|
|
@ -234,7 +234,7 @@ utils::result<std::vector<object::attribute>, utils::error> postgres_connection:
|
|||
}
|
||||
char *end = nullptr;
|
||||
// Todo: Handle error
|
||||
// auto index = strtoul(reader.column(0), &end, 10) - 1;
|
||||
auto index = strtoul(reader.column(0), &end, 10) - 1;
|
||||
std::string name = reader.column(1);
|
||||
|
||||
// Todo: extract size
|
||||
|
|
|
|||
|
|
@ -99,7 +99,6 @@ public:
|
|||
[[nodiscard]] utils::result<void, utils::error> attach(const std::string &table_name) const;
|
||||
|
||||
utils::result<void, utils::error> create_schema() const;
|
||||
utils::result<void, utils::error> drop_schema() const;
|
||||
|
||||
/**
|
||||
* Insert the given object into the session.
|
||||
|
|
@ -145,7 +144,6 @@ private:
|
|||
friend class query_select;
|
||||
|
||||
static query::fetchable_query build_select_query(entity_query_data &&data);
|
||||
static sql::query_context build_add_constraint_context(const std::string& table_name, const class object::constraint& cons, const sql::connection_ptr &conn) ;
|
||||
|
||||
private:
|
||||
mutable sql::statement_cache cache_;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class query_alter_intermediate : public query_intermediate {
|
|||
public:
|
||||
query_alter_intermediate();
|
||||
|
||||
[[nodiscard]] query_alter_table_intermediate table(const table &tab) const;
|
||||
query_alter_table_intermediate table(const table &tab) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ public:
|
|||
using query_intermediate::query_intermediate;
|
||||
|
||||
query_add_key_constraint_intermediate add_constraint(const std::string& name);
|
||||
executable_query add_constraint(const class object::constraint& constraint);
|
||||
executable_query drop_constraint(const std::string& name);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@
|
|||
#include "matador/object/attribute.hpp"
|
||||
#include "matador/object/constraint.hpp"
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace matador::query {
|
||||
|
||||
class query_create_table_columns_intermediate : public executable_query {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
#include "matador/utils/placeholder.hpp"
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
|
||||
namespace matador::query::internal {
|
||||
|
|
|
|||
|
|
@ -84,34 +84,38 @@ utils::result<void, utils::error> schema::create() const {
|
|||
}
|
||||
|
||||
utils::result<void, utils::error> schema::drop() const {
|
||||
std::vector<std::string> drop_sql_commands;
|
||||
auto c = pool_.acquire();
|
||||
// drop table constraints
|
||||
for (const auto &node: repo_) {
|
||||
for (const auto& cons : node->info().constraints()) {
|
||||
auto ctx = query::query::alter()
|
||||
.table(node->name())
|
||||
.drop_constraint(cons.name())
|
||||
.compile(*c);
|
||||
|
||||
std::cout << ctx.sql << std::endl;
|
||||
if (auto result = c->execute(ctx.sql); !result) {
|
||||
return utils::failure(result.err());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// drop table
|
||||
for (const auto &node: repo_) {
|
||||
auto ctx = query::query::drop()
|
||||
.table(node->name())
|
||||
.compile(*c);
|
||||
|
||||
std::cout << ctx.sql << std::endl;
|
||||
if (auto result = c->execute(ctx.sql); !result) {
|
||||
drop_sql_commands.push_back(ctx.sql);
|
||||
// determine constraints and drop them
|
||||
for (auto it = node->info().endpoint_begin(); it != node->info().endpoint_end(); ++it) {
|
||||
const auto& endpoint = *(it->second);
|
||||
if (endpoint.type() == object::relation_type::BELONGS_TO) {
|
||||
continue;
|
||||
}
|
||||
const auto drop_fk_ctx = query::query::alter()
|
||||
.table( endpoint.node().name() )
|
||||
.drop_constraint( "FK_" + endpoint.node().name() + "_" + endpoint.foreign_endpoint()->field_name() )
|
||||
.compile(*c);
|
||||
std::cout << drop_fk_ctx.sql << std::endl;
|
||||
if (auto result = c->execute(drop_fk_ctx.sql); !result) {
|
||||
return utils::failure(result.err());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// execute additional commands (e.g. ALTER TABLE ADD FK)
|
||||
for (const auto &sql: drop_sql_commands) {
|
||||
std::cout << sql << std::endl;
|
||||
if (auto result = c->execute(sql); !result) {
|
||||
return utils::failure(result.err());
|
||||
}
|
||||
}
|
||||
return utils::ok<void>();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,110 +20,59 @@ session::session(session_context&& ctx)
|
|||
|
||||
utils::result<void, utils::error> session::create_schema() const {
|
||||
// Step 1: Build dependency graph
|
||||
// std::unordered_map<std::string, std::vector<std::string> > dependency_graph;
|
||||
// std::unordered_map<std::string, std::pair<int,object::repository::node_ptr>> in_degree;
|
||||
std::unordered_map<std::string, std::vector<std::string> > dependency_graph;
|
||||
std::unordered_map<std::string, std::pair<int,object::repository::node_ptr>> in_degree;
|
||||
|
||||
// for (const auto &node: *schema_) {
|
||||
// for (auto it = node->info().endpoint_begin(); it != node->info().endpoint_end(); ++it) {
|
||||
// dependency_graph[node->name()].push_back(it->second->node().name());
|
||||
//
|
||||
// if (const auto dit = in_degree.find(it->second->node().name()); dit == in_degree.end()) {
|
||||
// in_degree[it->second->node().name()] = std::make_pair(1, it->second->node_ptr());
|
||||
// } else {
|
||||
// in_degree[it->second->node().name()].first++;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Ensure the current node exists in the graph representation
|
||||
// if (in_degree.find(node->name()) == in_degree.end()) {
|
||||
// in_degree[node->name()] = std::make_pair(0, node);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (const auto &it : dependency_graph) {
|
||||
// std::cout << "Dependency graph " << it.first << std::endl;
|
||||
// for (const auto &neighbor: it.second) {
|
||||
// std::cout << " " << neighbor << std::endl;
|
||||
// }
|
||||
// std::cout << std::endl;
|
||||
// }
|
||||
for (const auto &node: *schema_) {
|
||||
for (auto it = node->info().endpoint_begin(); it != node->info().endpoint_end(); ++it) {
|
||||
dependency_graph[node->name()].push_back(it->second->node().name());
|
||||
|
||||
if (const auto dit = in_degree.find(it->second->node().name()); dit == in_degree.end()) {
|
||||
in_degree[it->second->node().name()] = std::make_pair(1, it->second->node_ptr());
|
||||
} else {
|
||||
in_degree[it->second->node().name()].first++;
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure the current node exists in the graph representation
|
||||
if (in_degree.find(node->name()) == in_degree.end()) {
|
||||
in_degree[node->name()] = std::make_pair(0, node);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto &it : dependency_graph) {
|
||||
std::cout << "Dependency graph " << it.first << std::endl;
|
||||
for (const auto &neighbor: it.second) {
|
||||
std::cout << " " << neighbor << std::endl;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
std::vector<std::string> fk_sql_commands;
|
||||
auto c = cache_.pool().acquire();
|
||||
for (const auto &node: *schema_) {
|
||||
auto ctx = query::query::create()
|
||||
.table(node->name())
|
||||
.columns(node->info().attributes())
|
||||
.constraints(node->info().constraints())
|
||||
.compile(*c);
|
||||
|
||||
// for ( const auto& [sql, command] : ctx.additional_commands ) {
|
||||
// fk_sql_commands.push_back( sql );
|
||||
// }
|
||||
std::cout << ctx.sql << std::endl;
|
||||
if (auto result = c->execute(ctx.sql); !result) {
|
||||
return utils::failure(result.err());
|
||||
}
|
||||
}
|
||||
|
||||
// create table constraints
|
||||
for (const auto &node: *schema_) {
|
||||
for (const auto& cons : node->info().constraints()) {
|
||||
auto ctx = build_add_constraint_context(node->name(), cons, c);
|
||||
|
||||
std::cout << ctx.sql << std::endl;
|
||||
if (auto result = c->execute(ctx.sql); !result) {
|
||||
// execute additional commands (e.g. ALTER TABLE ADD FK)
|
||||
for (const auto &sql: fk_sql_commands) {
|
||||
std::cout << sql << std::endl;
|
||||
if (auto result = c->execute(sql); !result) {
|
||||
return utils::failure(result.err());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return utils::ok<void>();
|
||||
}
|
||||
|
||||
sql::query_context session::build_add_constraint_context(const std::string& table_name, const class object::constraint& cons, const sql::connection_ptr &conn) {
|
||||
if (cons.is_foreign_key_constraint()) {
|
||||
return query::query::alter()
|
||||
.table(table_name)
|
||||
.add_constraint( cons.name() )
|
||||
.foreign_key(cons.column_name())
|
||||
.references(cons.ref_table_name(), {cons.ref_column_name()})
|
||||
.compile(*conn);
|
||||
}
|
||||
if (cons.is_primary_key_constraint()) {
|
||||
return query::query::alter()
|
||||
.table(table_name)
|
||||
.add_constraint( cons.name() )
|
||||
.primary_key(cons.column_name())
|
||||
.compile(*conn);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
utils::result<void, utils::error> session::drop_schema() const {
|
||||
auto c = cache_.pool().acquire();
|
||||
// drop table constraints
|
||||
for (const auto &node: *schema_) {
|
||||
for (const auto& cons : node->info().constraints()) {
|
||||
auto ctx = query::query::alter()
|
||||
.table(node->name())
|
||||
.drop_constraint(cons.name())
|
||||
.compile(*c);
|
||||
|
||||
std::cout << ctx.sql << std::endl;
|
||||
if (auto result = c->execute(ctx.sql); !result) {
|
||||
return utils::failure(result.err());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// drop table
|
||||
for (const auto &node: *schema_) {
|
||||
auto ctx = query::query::drop()
|
||||
.table(node->name())
|
||||
.compile(*c);
|
||||
|
||||
std::cout << ctx.sql << std::endl;
|
||||
if (auto result = c->execute(ctx.sql); !result) {
|
||||
return utils::failure(result.err());
|
||||
}
|
||||
}
|
||||
|
||||
return utils::ok<void>();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,10 @@ query_add_key_constraint_intermediate query_alter_table_intermediate::add_constr
|
|||
return {context_};
|
||||
}
|
||||
|
||||
executable_query query_alter_table_intermediate::add_constraint( const class object::constraint& constraint ) {
|
||||
return {context_};
|
||||
}
|
||||
|
||||
executable_query query_alter_table_intermediate::drop_constraint( const std::string& name ) {
|
||||
context_->parts.push_back(std::make_unique<internal::query_drop_key_constraint_part>(name));
|
||||
return {context_};
|
||||
|
|
|
|||
|
|
@ -36,6 +36,9 @@ sql::query_context query_compiler::compile(const query_data &data,
|
|||
}
|
||||
|
||||
std::string handle_column(sql::query_context &ctx, const sql::dialect *d, const query_data &data, const column &col) {
|
||||
// ctx.result_vars.emplace_back(col.column_name());
|
||||
const auto& column_table = col.table().get();
|
||||
// ctx.column_aliases.insert({column_table->has_alias() ? column_table->alias() : column_table->name() + "." + col.column_name(), col.alias()});
|
||||
if (col.is_function()) {
|
||||
ctx.prototype.emplace_back(col.has_alias() ? col.alias() : col.column_name());
|
||||
ctx.prototype.back().change_type(utils::basic_type::type_int32);
|
||||
|
|
@ -150,6 +153,7 @@ void query_compiler::visit(internal::query_select_part &part) {
|
|||
void query_compiler::visit(internal::query_from_part &part) {
|
||||
query_.table_name = part.table().name();
|
||||
query_.sql += " " + build_table_name(part.token(), *dialect_, part.table());
|
||||
// query_.table_aliases.insert({query_.table_name, part.table().alias()});
|
||||
}
|
||||
|
||||
void query_compiler::visit(internal::query_join_part &part)
|
||||
|
|
@ -173,33 +177,40 @@ void query_compiler::visit(internal::query_group_by_part &part) {
|
|||
query_.sql += " " + dialect_->group_by() + " " + prepare_identifier(*dialect_, part.column());
|
||||
}
|
||||
|
||||
void query_compiler::visit(internal::query_order_by_part &part) {
|
||||
void query_compiler::visit(internal::query_order_by_part &part)
|
||||
{
|
||||
query_.sql += " " + dialect_->order_by() +
|
||||
" " + prepare_criteria(*dialect_, part.column());
|
||||
}
|
||||
|
||||
void query_compiler::visit(internal::query_order_by_asc_part &/*order_by_asc_part*/) {
|
||||
void query_compiler::visit(internal::query_order_by_asc_part &/*order_by_asc_part*/)
|
||||
{
|
||||
query_.sql += " " + dialect_->asc();
|
||||
}
|
||||
|
||||
void query_compiler::visit(internal::query_order_by_desc_part &/*order_by_desc_part*/) {
|
||||
void query_compiler::visit(internal::query_order_by_desc_part &/*order_by_desc_part*/)
|
||||
{
|
||||
query_.sql += " " + dialect_->desc();
|
||||
}
|
||||
|
||||
void query_compiler::visit(internal::query_offset_part &part) {
|
||||
void query_compiler::visit(internal::query_offset_part &part)
|
||||
{
|
||||
query_.sql += " " + dialect_->offset() + " " + std::to_string(part.offset());
|
||||
}
|
||||
|
||||
void query_compiler::visit(internal::query_limit_part &part) {
|
||||
void query_compiler::visit(internal::query_limit_part &part)
|
||||
{
|
||||
query_.sql += " " + dialect_->limit() + " " + std::to_string(part.limit());
|
||||
}
|
||||
|
||||
void query_compiler::visit(internal::query_insert_part &/*insert_part*/) {
|
||||
void query_compiler::visit(internal::query_insert_part &/*insert_part*/)
|
||||
{
|
||||
query_.command = sql::sql_command::SQL_INSERT;
|
||||
query_.sql = dialect_->insert();
|
||||
}
|
||||
|
||||
void query_compiler::visit(internal::query_into_part &part) {
|
||||
void query_compiler::visit(internal::query_into_part &part)
|
||||
{
|
||||
query_.table_name = part.table().name();
|
||||
query_.sql += " " + dialect_->into() +
|
||||
" " + dialect_->prepare_identifier_string(part.table().name());
|
||||
|
|
@ -372,12 +383,14 @@ void query_compiler::visit(internal::query_set_part &part) {
|
|||
query_.sql += result;
|
||||
}
|
||||
|
||||
void query_compiler::visit(internal::query_drop_table_part &part) {
|
||||
void query_compiler::visit(internal::query_drop_table_part &part)
|
||||
{
|
||||
query_.table_name = part.table().name();
|
||||
query_.sql += " " + build_table_name(part.token(), *dialect_, query_.table_name);
|
||||
}
|
||||
|
||||
std::string build_create_column(const object::attribute &col, const sql::dialect &d) {
|
||||
std::string build_create_column(const object::attribute &col, const sql::dialect &d)
|
||||
{
|
||||
std::string result = d.prepare_identifier_string(col.name()) + " " + d.data_type_at(col.type());
|
||||
if (col.attributes().size() > 0) {
|
||||
result.append("(" + std::to_string(col.attributes().size()) + ")");
|
||||
|
|
@ -420,7 +433,8 @@ std::string build_constraint(const class object::constraint& cons, const sql::di
|
|||
return result;
|
||||
}
|
||||
|
||||
std::string query_compiler::build_table_name(const sql::dialect_token token, const sql::dialect &d, const table& t) {
|
||||
std::string query_compiler::build_table_name(const sql::dialect_token token, const sql::dialect &d, const table& t)
|
||||
{
|
||||
return d.token_at(token) + " " +
|
||||
(!d.default_schema_name().empty() ? d.prepare_identifier_string(d.default_schema_name()) + "." : "") +
|
||||
d.prepare_identifier_string(t.name()) +
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ TEST_CASE_METHOD( QueryFixture, "Insert and select basic datatypes", "[query][da
|
|||
ullval = (std::numeric_limits<long long>::max)();
|
||||
}
|
||||
bool bval = true;
|
||||
// const char *cstr("Armer schwarzer Kater");
|
||||
const char *cstr("Armer schwarzer Kater");
|
||||
std::string varcharval("hallo welt");
|
||||
std::string strval = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam "
|
||||
"nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, "
|
||||
|
|
|
|||
|
|
@ -5,12 +5,13 @@
|
|||
namespace matador::test {
|
||||
|
||||
SessionFixture::SessionFixture()
|
||||
: pool(connection::dns, 4)
|
||||
, ses({bus, pool}) {}
|
||||
: pool(connection::dns, 4), ses({bus, pool}) {}
|
||||
|
||||
SessionFixture::~SessionFixture() {
|
||||
const auto result = ses.drop_schema();
|
||||
REQUIRE(result.is_ok());
|
||||
while (!tables_to_drop.empty()) {
|
||||
drop_table_if_exists(tables_to_drop.top());
|
||||
tables_to_drop.pop();
|
||||
}
|
||||
}
|
||||
|
||||
void SessionFixture::drop_table_if_exists(const std::string &table_name) const {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ public:
|
|||
|
||||
protected:
|
||||
sql::connection_pool pool;
|
||||
std::stack <std::string> tables_to_drop;
|
||||
orm::session ses;
|
||||
utils::message_bus bus;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ TEST_CASE_METHOD(SessionFixture, "Session insert test", "[session][insert]") {
|
|||
.and_then([this] { return ses.create_schema(); } );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
tables_to_drop.emplace("airplanes");
|
||||
|
||||
auto plane = ses.insert<airplane>(1, "Boeing", "A380");
|
||||
REQUIRE(plane.is_ok());
|
||||
|
||||
|
|
@ -36,6 +38,8 @@ TEST_CASE_METHOD(SessionFixture, "Session update test", "[session][update]") {
|
|||
.and_then([this] { return ses.create_schema(); } );
|
||||
REQUIRE(res.is_ok());
|
||||
|
||||
tables_to_drop.emplace("airplanes");
|
||||
|
||||
auto result = ses.insert<airplane>(1, "Boeing", "747");
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
|
|
@ -66,6 +70,8 @@ TEST_CASE_METHOD(SessionFixture, "Session delete test", "[session][delete]") {
|
|||
.and_then([this] { return ses.create_schema(); } );
|
||||
REQUIRE(res.is_ok());
|
||||
|
||||
tables_to_drop.emplace("airplanes");
|
||||
|
||||
auto result = ses.insert<airplane>(1, "Boeing", "747");
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
|
|
@ -88,6 +94,9 @@ TEST_CASE_METHOD(SessionFixture, "Session relation test", "[session][relation]")
|
|||
.and_then([this] { return ses.create_schema(); } );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
tables_to_drop.emplace("airplanes");
|
||||
tables_to_drop.emplace("flights");
|
||||
|
||||
auto plane = ses.insert<airplane>(1, "Boeing", "A380");
|
||||
REQUIRE(plane.is_ok());
|
||||
auto f = ses.insert<flight>(2, *plane, "sully");
|
||||
|
|
@ -109,6 +118,8 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find object with id", "[session
|
|||
.and_then([this] { return ses.create_schema(); } );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
tables_to_drop.emplace("airplanes");
|
||||
|
||||
auto a380 = ses.insert<airplane>(1, "Boeing", "A380");
|
||||
REQUIRE(a380.is_ok());
|
||||
|
||||
|
|
@ -128,6 +139,8 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects", "[session][f
|
|||
.and_then([this] { return ses.create_schema(); } );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
tables_to_drop.emplace("airplanes");
|
||||
|
||||
std::vector<std::unique_ptr<airplane>> planes;
|
||||
planes.emplace_back(new airplane(1, "Airbus", "A380"));
|
||||
planes.emplace_back(new airplane(2, "Boeing", "707"));
|
||||
|
|
@ -161,6 +174,9 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with one-to-ma
|
|||
.and_then( [this] { return ses.attach<book>("books"); } )
|
||||
.and_then( [this] { return ses.create_schema(); } );
|
||||
|
||||
tables_to_drop.emplace("authors");
|
||||
tables_to_drop.emplace("books");
|
||||
|
||||
std::vector<std::unique_ptr<author>> authors;
|
||||
authors.emplace_back(new author{1, "Michael", "Crichton", "23.10.1942", 1975, true, {}});
|
||||
authors.emplace_back(new author{ 2, "Steven", "King", "21.9.1947", 1956, false, {}});
|
||||
|
|
@ -211,6 +227,9 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with one-to-ma
|
|||
.and_then( [this] { return ses.attach<employee>("employees"); } )
|
||||
.and_then( [this] { return ses.create_schema(); } );
|
||||
|
||||
tables_to_drop.emplace("departments");
|
||||
tables_to_drop.emplace("employees");
|
||||
|
||||
std::vector<std::unique_ptr<department>> departments;
|
||||
departments.emplace_back(new department{1, "Insurance", {}});
|
||||
departments.emplace_back(new department{ 2, "Invoice", {}});
|
||||
|
|
@ -264,6 +283,10 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with many-to-m
|
|||
.and_then( [this] { return ses.attach<ingredient>("ingredients"); } )
|
||||
.and_then( [this] { return ses.create_schema(); } );
|
||||
|
||||
tables_to_drop.emplace("recipes");
|
||||
tables_to_drop.emplace("ingredients");
|
||||
tables_to_drop.emplace("recipe_ingredients");
|
||||
|
||||
std::vector<std::unique_ptr<ingredient>> ingredients;
|
||||
ingredients.push_back(std::make_unique<ingredient>(1, "Apple"));
|
||||
ingredients.push_back(std::make_unique<ingredient>(2, "Strawberry"));
|
||||
|
|
|
|||
|
|
@ -62,7 +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), 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]") {
|
||||
|
|
|
|||
Loading…
Reference in New Issue