schema progress (does not compile)
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
#include "catch2/catch_test_macros.hpp"
|
||||
#include "catch2/matchers/catch_matchers_string.hpp"
|
||||
|
||||
#include "matador/object/attribute.hpp"
|
||||
#include "matador/object/repository.hpp"
|
||||
|
||||
#include "matador/sql/connection.hpp"
|
||||
#include "matador/sql/dialect.hpp"
|
||||
|
||||
#include "matador/query/criteria.hpp"
|
||||
#include "matador/query/generator.hpp"
|
||||
#include "matador/query/query.hpp"
|
||||
#include "matador/query/schema.hpp"
|
||||
|
||||
#include "matador/utils/basic_types.hpp"
|
||||
#include "matador/utils/string.hpp"
|
||||
@@ -25,9 +23,9 @@ using namespace matador::sql;
|
||||
using namespace matador::object;
|
||||
using namespace matador::query;
|
||||
|
||||
TEST_CASE_METHOD( QueryFixture, "Insert and select basic datatypes", "[query][datatypes]" ) {
|
||||
TEST_CASE_METHOD(QueryFixture, "Insert and select basic datatypes", "[query][datatypes]") {
|
||||
REQUIRE(repo.attach<types>("types"));
|
||||
auto obj = object_generator::generate<types>(repo, "types");
|
||||
auto obj = object_generator::generate<types>(repo.repo(), "types");
|
||||
auto res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
@@ -290,7 +288,7 @@ TEST_CASE_METHOD(QueryFixture, "Test describe table", "[query][describe][table]"
|
||||
using namespace matador::sql;
|
||||
|
||||
REQUIRE(repo.attach<types>("types"));
|
||||
auto obj = object_generator::generate<types>(repo, "types");
|
||||
auto obj = object_generator::generate<types>(repo.repo(), "types");
|
||||
auto res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
@@ -368,7 +366,7 @@ TEST_CASE_METHOD(QueryFixture, "Test primary key", "[query][primary key]") {
|
||||
using namespace matador::sql;
|
||||
|
||||
REQUIRE(repo.attach<pk>("pk"));
|
||||
auto obj = object_generator::generate<pk>(repo, "pk");
|
||||
auto obj = object_generator::generate<pk>(repo.repo(), "pk");
|
||||
auto res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
@@ -400,7 +398,7 @@ TEST_CASE_METHOD(QueryFixture, "Test primary key prepared", "[query][primary key
|
||||
using namespace matador::sql;
|
||||
|
||||
REQUIRE(repo.attach<pk>("pk"));
|
||||
auto obj = object_generator::generate<pk>(repo, "pk");
|
||||
auto obj = object_generator::generate<pk>(repo.repo(), "pk");
|
||||
auto res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "matador/sql/dialect.hpp"
|
||||
|
||||
#include "connection.hpp"
|
||||
|
||||
#include "catch2/catch_test_macros.hpp"
|
||||
|
||||
namespace matador::test {
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
#ifndef MATADOR_QUERY_FIXTURE_HPP
|
||||
#define MATADOR_QUERY_FIXTURE_HPP
|
||||
|
||||
#include "matador/object/repository.hpp"
|
||||
#include "matador/query/schema.hpp"
|
||||
|
||||
#include "matador/sql/connection.hpp"
|
||||
|
||||
#include "connection.hpp"
|
||||
|
||||
#include <stack>
|
||||
|
||||
namespace matador::test {
|
||||
@@ -22,7 +20,7 @@ public:
|
||||
protected:
|
||||
sql::connection db;
|
||||
std::stack <std::string> tables_to_drop;
|
||||
object::repository repo;
|
||||
query::schema repo;
|
||||
|
||||
private:
|
||||
void drop_table_if_exists(const std::string &table_name) const;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "matador/sql/connection.hpp"
|
||||
|
||||
#include "matador/query/builder.hpp"
|
||||
#include "matador/query/criteria.hpp"
|
||||
#include "matador/query/query.hpp"
|
||||
#include "matador/query/column.hpp"
|
||||
@@ -23,26 +24,31 @@ using namespace matador::utils;
|
||||
TEST_CASE_METHOD(QueryFixture, "Test all data types for record", "[query][record][data types]") {
|
||||
check_table_not_exists("types");
|
||||
|
||||
const table tab("types");
|
||||
|
||||
// auto r = query::create().table(tab).columns({
|
||||
// column("id", basic_type::UInt32)
|
||||
// });
|
||||
auto res = query::create()
|
||||
.table("types")
|
||||
.table(tab)
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("val_char", basic_type::Int8),
|
||||
attribute("val_short", basic_type::Int16),
|
||||
attribute("val_int", basic_type::Int32),
|
||||
attribute("val_long_long", basic_type::Int64),
|
||||
attribute("val_uchar", basic_type::UInt8),
|
||||
attribute("val_ushort", basic_type::UInt16),
|
||||
attribute("val_uint", basic_type::UInt32),
|
||||
attribute("val_ulong_long", basic_type::UInt64),
|
||||
attribute("val_bool", basic_type::Boolean),
|
||||
attribute("val_float", basic_type::Float),
|
||||
attribute("val_double", basic_type::Double),
|
||||
attribute("val_string", basic_type::Text),
|
||||
attribute("val_varchar", basic_type::Varchar, 63),
|
||||
// attribute("val_date", basic_type::type_date),
|
||||
// attribute("val_time", basic_type::type_time),
|
||||
attribute("val_blob", basic_type::Blob),
|
||||
column("id", basic_type::UInt32),
|
||||
column("val_char", basic_type::Int8),
|
||||
column("val_short", basic_type::Int16),
|
||||
column("val_int", basic_type::Int32),
|
||||
column("val_long_long", basic_type::Int64),
|
||||
column("val_uchar", basic_type::UInt8),
|
||||
column("val_ushort", basic_type::UInt16),
|
||||
column("val_uint", basic_type::UInt32),
|
||||
column("val_ulong_long", basic_type::UInt64),
|
||||
column("val_bool", basic_type::Boolean),
|
||||
column("val_float", basic_type::Float),
|
||||
column("val_double", basic_type::Double),
|
||||
column("val_string", basic_type::Text),
|
||||
column("val_varchar", basic_type::Varchar, 63),
|
||||
// column("val_date", basic_type::type_date),
|
||||
// column("val_time", basic_type::type_time),
|
||||
column("val_blob", basic_type::Blob),
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_types").primary_key("id")
|
||||
@@ -126,9 +132,9 @@ TEST_CASE_METHOD(QueryFixture, "Create and drop table statement", "[query][recor
|
||||
auto res = query::create()
|
||||
.table("person")
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("name", basic_type::Varchar, 255),
|
||||
attribute("age", basic_type::UInt16)
|
||||
column("id", basic_type::UInt32),
|
||||
column("name", basic_type::Varchar, 255),
|
||||
column("age", basic_type::UInt16)
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_person").primary_key("id")
|
||||
@@ -154,9 +160,9 @@ TEST_CASE_METHOD(QueryFixture, "Create and drop table statement with foreign key
|
||||
auto res = query::create()
|
||||
.table("airplane")
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("brand", basic_type::Varchar, 255),
|
||||
attribute("model", basic_type::Varchar, 255),
|
||||
column("id", basic_type::UInt32),
|
||||
column("brand", basic_type::Varchar, 255),
|
||||
column("model", basic_type::Varchar, 255),
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_airplane").primary_key("id"),
|
||||
@@ -171,9 +177,9 @@ TEST_CASE_METHOD(QueryFixture, "Create and drop table statement with foreign key
|
||||
res = query::create()
|
||||
.table("flight")
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("airplane_id", basic_type::UInt32),
|
||||
attribute("pilot_name", basic_type::Varchar, 255)
|
||||
column("id", basic_type::UInt32),
|
||||
column("airplane_id", basic_type::UInt32),
|
||||
column("pilot_name", basic_type::Varchar, 255)
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_flight").primary_key("id"),
|
||||
@@ -208,9 +214,9 @@ TEST_CASE_METHOD(QueryFixture, "Execute insert record statement", "[query][recor
|
||||
auto res = query::create()
|
||||
.table("person")
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("name", basic_type::Varchar, 255),
|
||||
attribute("age", basic_type::UInt16)
|
||||
column("id", basic_type::UInt32),
|
||||
column("name", basic_type::Varchar, 255),
|
||||
column("age", basic_type::UInt16)
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_person").primary_key("id")
|
||||
@@ -251,9 +257,9 @@ TEST_CASE_METHOD(QueryFixture, "Execute insert record statement with foreign key
|
||||
auto res = query::create()
|
||||
.table("airplane")
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("brand", basic_type::Varchar, 255),
|
||||
attribute("model", basic_type::Varchar, 255),
|
||||
column("id", basic_type::UInt32),
|
||||
column("brand", basic_type::Varchar, 255),
|
||||
column("model", basic_type::Varchar, 255),
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_airplane").primary_key("id"),
|
||||
@@ -266,9 +272,9 @@ TEST_CASE_METHOD(QueryFixture, "Execute insert record statement with foreign key
|
||||
res = query::create()
|
||||
.table("flight")
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("airplane_id", basic_type::UInt32),
|
||||
attribute("pilot_name", basic_type::Varchar, 255)
|
||||
column("id", basic_type::UInt32),
|
||||
column("airplane_id", basic_type::UInt32),
|
||||
column("pilot_name", basic_type::Varchar, 255)
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_flight").primary_key("id"),
|
||||
@@ -314,9 +320,9 @@ TEST_CASE_METHOD(QueryFixture, "Execute update record statement", "[query][recor
|
||||
auto res = query::create()
|
||||
.table("person")
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("name", basic_type::Varchar, 255),
|
||||
attribute("age", basic_type::UInt16)
|
||||
column("id", basic_type::UInt32),
|
||||
column("name", basic_type::Varchar, 255),
|
||||
column("age", basic_type::UInt16)
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_person").primary_key("id")
|
||||
@@ -367,9 +373,9 @@ TEST_CASE_METHOD(QueryFixture, "Execute select statement", "[query][record]")
|
||||
auto res = query::create()
|
||||
.table("person")
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("name", basic_type::Varchar, 255),
|
||||
attribute("age", basic_type::UInt16)
|
||||
column("id", basic_type::UInt32),
|
||||
column("name", basic_type::Varchar, 255),
|
||||
column("age", basic_type::UInt16)
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_person").primary_key("id")
|
||||
@@ -427,9 +433,9 @@ TEST_CASE_METHOD(QueryFixture, "Execute select statement with order by", "[query
|
||||
auto res = query::create()
|
||||
.table("person")
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("name", basic_type::Varchar, 255),
|
||||
attribute("age", basic_type::UInt16)
|
||||
column("id", basic_type::UInt32),
|
||||
column("name", basic_type::Varchar, 255),
|
||||
column("age", basic_type::UInt16)
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_person").primary_key("id")
|
||||
@@ -473,9 +479,9 @@ TEST_CASE_METHOD(QueryFixture, "Execute select statement with group by and order
|
||||
auto res = query::create()
|
||||
.table("person")
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("name", basic_type::Varchar, 255),
|
||||
attribute("age", basic_type::UInt16)
|
||||
column("id", basic_type::UInt32),
|
||||
column("name", basic_type::Varchar, 255),
|
||||
column("age", basic_type::UInt16)
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_person").primary_key("id")
|
||||
@@ -526,9 +532,9 @@ TEST_CASE_METHOD(QueryFixture, "Execute delete statement", "[query][record]") {
|
||||
auto res = query::create()
|
||||
.table("person")
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("name", basic_type::Varchar, 255),
|
||||
attribute("age", basic_type::UInt16)
|
||||
column("id", basic_type::UInt32),
|
||||
column("name", basic_type::Varchar, 255),
|
||||
column("age", basic_type::UInt16)
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_person").primary_key("id")
|
||||
@@ -576,8 +582,8 @@ TEST_CASE_METHOD(QueryFixture, "Test quoted identifier record", "[query][record]
|
||||
auto res = query::create()
|
||||
.table("quotes")
|
||||
.columns({
|
||||
attribute("from", basic_type::Varchar, 255),
|
||||
attribute("to", basic_type::Varchar, 255)
|
||||
column("from", basic_type::Varchar, 255),
|
||||
column("to", basic_type::Varchar, 255)
|
||||
})
|
||||
.execute(db);
|
||||
REQUIRE(res.is_ok());
|
||||
@@ -637,9 +643,9 @@ TEST_CASE_METHOD(QueryFixture, "Test create record", "[query][record][create]")
|
||||
auto res = query::create()
|
||||
.table("person")
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("name", basic_type::Varchar, 255),
|
||||
attribute("age", basic_type::UInt16)
|
||||
column("id", basic_type::UInt32),
|
||||
column("name", basic_type::Varchar, 255),
|
||||
column("age", basic_type::UInt16)
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_person").primary_key("id")
|
||||
@@ -664,9 +670,9 @@ TEST_CASE_METHOD(QueryFixture, "Test insert record", "[query][record][insert]")
|
||||
auto res = query::create()
|
||||
.table("person")
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("name", basic_type::Varchar, 255),
|
||||
attribute("age", basic_type::UInt16)
|
||||
column("id", basic_type::UInt32),
|
||||
column("name", basic_type::Varchar, 255),
|
||||
column("age", basic_type::UInt16)
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_person").primary_key("id")
|
||||
@@ -701,9 +707,9 @@ TEST_CASE_METHOD(QueryFixture, "Test update record", "[query][record][update]")
|
||||
auto res = query::create()
|
||||
.table("person")
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("name", basic_type::Varchar, 255),
|
||||
attribute("age", basic_type::UInt16)
|
||||
column("id", basic_type::UInt32),
|
||||
column("name", basic_type::Varchar, 255),
|
||||
column("age", basic_type::UInt16)
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_person").primary_key("id")
|
||||
@@ -755,9 +761,9 @@ TEST_CASE_METHOD(QueryFixture, "Test prepared record statement", "[query][record
|
||||
auto stmt = query::create()
|
||||
.table("person")
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("name", basic_type::Varchar, 255),
|
||||
attribute("age", basic_type::UInt16)
|
||||
column("id", basic_type::UInt32),
|
||||
column("name", basic_type::Varchar, 255),
|
||||
column("age", basic_type::UInt16)
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_person").primary_key("id")
|
||||
@@ -785,7 +791,7 @@ TEST_CASE_METHOD(QueryFixture, "Test scalar result", "[query][record][scalar][re
|
||||
auto res = query::create()
|
||||
.table("person")
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32)
|
||||
column("id", basic_type::UInt32)
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_person").primary_key("id")
|
||||
|
||||
@@ -20,7 +20,7 @@ using namespace matador::test;
|
||||
|
||||
TEST_CASE_METHOD(QueryFixture, "Test create statement", "[query][statement][create]") {
|
||||
REQUIRE(repo.attach<matador::test::person>("person"));
|
||||
const auto obj = object_generator::generate<person>(repo, "person");
|
||||
const auto obj = object_generator::generate<person>(repo.repo(), "person");
|
||||
auto stmt = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
@@ -47,12 +47,12 @@ TEST_CASE_METHOD(QueryFixture, "Test insert statement", "[query][statement][inse
|
||||
using namespace matador::test;
|
||||
|
||||
REQUIRE(repo.attach<person>("person"));
|
||||
const auto obj = object_generator::generate<person>(repo, "person");
|
||||
auto stmt = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
.constraints(obj->constraints())
|
||||
.prepare(db);
|
||||
const auto obj = object_generator::generate<person>(repo.repo(), "person");
|
||||
auto stmt = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
.constraints(obj->constraints())
|
||||
.prepare(db);
|
||||
REQUIRE(stmt);
|
||||
|
||||
auto res = stmt->execute();
|
||||
@@ -92,12 +92,12 @@ TEST_CASE_METHOD(QueryFixture, "Test update statement", "[query][statement][upda
|
||||
using namespace matador::utils;
|
||||
|
||||
REQUIRE(repo.attach<matador::test::person>("person"));
|
||||
const auto obj = object_generator::generate<person>(repo, "person");
|
||||
auto stmt = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
.constraints(obj->constraints())
|
||||
.prepare(db);
|
||||
const auto obj = object_generator::generate<person>(repo.repo(), "person");
|
||||
auto stmt = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
.constraints(obj->constraints())
|
||||
.prepare(db);
|
||||
REQUIRE(stmt);
|
||||
|
||||
auto res = stmt->execute();
|
||||
@@ -161,12 +161,12 @@ TEST_CASE_METHOD(QueryFixture, "Test delete statement", "[query][statement][dele
|
||||
using namespace matador::test;
|
||||
|
||||
REQUIRE(repo.attach<matador::test::person>("person"));
|
||||
const auto obj = object_generator::generate<person>(repo, "person");
|
||||
auto stmt = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
.constraints(obj->constraints())
|
||||
.prepare(db);
|
||||
const auto obj = object_generator::generate<person>(repo.repo(), "person");
|
||||
auto stmt = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
.constraints(obj->constraints())
|
||||
.prepare(db);
|
||||
REQUIRE(stmt);
|
||||
|
||||
auto res = stmt->execute();
|
||||
@@ -251,12 +251,12 @@ TEST_CASE_METHOD(QueryFixture, "Test reuse prepared statement", "[query][stateme
|
||||
using namespace matador::test;
|
||||
|
||||
REQUIRE(repo.attach<matador::test::person>("person"));
|
||||
const auto obj = object_generator::generate<person>(repo, "person");
|
||||
auto stmt = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
.constraints(obj->constraints())
|
||||
.prepare(db);
|
||||
const auto obj = object_generator::generate<person>(repo.repo(), "person");
|
||||
auto stmt = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
.constraints(obj->constraints())
|
||||
.prepare(db);
|
||||
REQUIRE(stmt);
|
||||
|
||||
auto res = stmt->execute();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "catch2/catch_test_macros.hpp"
|
||||
|
||||
#include "matador/object/attribute.hpp"
|
||||
|
||||
#include "matador/query/builder.hpp"
|
||||
#include "matador/query/criteria.hpp"
|
||||
#include "matador/query/generator.hpp"
|
||||
#include "matador/query/query.hpp"
|
||||
@@ -23,7 +22,7 @@ TEST_CASE_METHOD(QueryFixture, "Create table with foreign key relation", "[query
|
||||
.and_then( [this] { return repo.attach<flight>("flight");} );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
auto obj = object_generator::generate<airplane>(repo, "airplane");
|
||||
auto obj = object_generator::generate<airplane>(repo.repo(), "airplane");
|
||||
auto res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
@@ -35,7 +34,7 @@ TEST_CASE_METHOD(QueryFixture, "Create table with foreign key relation", "[query
|
||||
check_table_exists("airplane");
|
||||
tables_to_drop.emplace("airplane");
|
||||
|
||||
obj = object_generator::generate<flight>(repo, "flight");
|
||||
obj = object_generator::generate<flight>(repo.repo(), "flight");
|
||||
res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
@@ -50,7 +49,7 @@ TEST_CASE_METHOD(QueryFixture, "Create table with foreign key relation", "[query
|
||||
|
||||
TEST_CASE_METHOD(QueryFixture, "Execute select statement with where clause", "[query][where]") {
|
||||
REQUIRE(repo.attach<person>("person"));
|
||||
const auto obj = object_generator::generate<person>(repo, "person");
|
||||
const auto obj = object_generator::generate<person>(repo.repo(), "person");
|
||||
auto res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
@@ -110,9 +109,9 @@ TEST_CASE_METHOD(QueryFixture, "Execute insert statement", "[query][insert]") {
|
||||
auto res = query::create()
|
||||
.table("person")
|
||||
.columns({
|
||||
attribute("id", matador::utils::basic_type::UInt32),
|
||||
attribute("name", matador::utils::basic_type::Varchar, 255),
|
||||
attribute("color", matador::utils::basic_type::Varchar, 63)
|
||||
column("id", matador::utils::basic_type::UInt32),
|
||||
column("name", matador::utils::basic_type::Varchar, 255),
|
||||
column("color", matador::utils::basic_type::Varchar, 63)
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_person").primary_key("id")
|
||||
|
||||
@@ -15,46 +15,48 @@ using namespace matador::test;
|
||||
|
||||
TEST_CASE_METHOD(SchemaFixture, "Test schema one-two-many", "[schema][one-to-many]") {
|
||||
using namespace matador::test;
|
||||
query::schema repo(pool/*, "NoopSchema"*/);
|
||||
query::schema repo;
|
||||
|
||||
auto result = repo.attach<department>("departments")
|
||||
.and_then([&repo] { return repo.attach<employee>("employees"); });
|
||||
REQUIRE(result);
|
||||
|
||||
result = repo.create();
|
||||
auto conn = pool.acquire();
|
||||
result = repo.create(*conn);
|
||||
REQUIRE(result);
|
||||
|
||||
auto exists_result = repo.table_exists("departments");
|
||||
auto exists_result = repo.table_exists("departments", *conn);
|
||||
REQUIRE(exists_result.is_ok());
|
||||
REQUIRE(exists_result.value());
|
||||
|
||||
result = repo.drop();
|
||||
result = repo.drop(*conn);
|
||||
REQUIRE(result);
|
||||
|
||||
exists_result = repo.table_exists("departments");
|
||||
exists_result = repo.table_exists("departments", *conn);
|
||||
REQUIRE(exists_result.is_ok());
|
||||
REQUIRE(!exists_result.value());
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SchemaFixture, "Test schema many-to-many", "[schema][many-to-many]") {
|
||||
using namespace matador::test;
|
||||
query::schema repo(pool/*, "NoopSchema"*/);
|
||||
query::schema repo;
|
||||
|
||||
auto result = repo.attach<recipe>("recipes")
|
||||
.and_then([&repo] { return repo.attach<ingredient>("ingredients"); });
|
||||
REQUIRE(result);
|
||||
|
||||
result = repo.create();
|
||||
auto conn = pool.acquire();
|
||||
result = repo.create(*conn);
|
||||
REQUIRE(result);
|
||||
|
||||
auto exists_result = repo.table_exists("recipes");
|
||||
auto exists_result = repo.table_exists("recipes", *conn);
|
||||
REQUIRE(exists_result.is_ok());
|
||||
REQUIRE(exists_result.value());
|
||||
|
||||
result = repo.drop();
|
||||
result = repo.drop(*conn);
|
||||
REQUIRE(result);
|
||||
|
||||
exists_result = repo.table_exists("recipes");
|
||||
exists_result = repo.table_exists("recipes", *conn);
|
||||
REQUIRE(exists_result.is_ok());
|
||||
REQUIRE(!exists_result.value());
|
||||
}
|
||||
|
||||
@@ -23,18 +23,15 @@ using namespace matador::test;
|
||||
|
||||
namespace matador::test::detail {
|
||||
template<class Type, typename... Args>
|
||||
[[maybe_unused]] object_ptr<Type> make_object_ptr(Args&&... args)
|
||||
{
|
||||
[[maybe_unused]] object_ptr<Type> make_object_ptr(Args&&... args) {
|
||||
return object_ptr(new Type(std::forward<Args>(args)...));
|
||||
}
|
||||
}
|
||||
|
||||
class StatementTestFixture : public QueryFixture
|
||||
{
|
||||
class StatementTestFixture : public QueryFixture {
|
||||
public:
|
||||
StatementTestFixture()
|
||||
{
|
||||
const auto obj = object_generator::generate<airplane>(repo, "airplane");
|
||||
StatementTestFixture() {
|
||||
const auto obj = object_generator::generate<airplane>(repo.repo(), "airplane");
|
||||
const auto res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
|
||||
@@ -22,7 +22,7 @@ class TypeTraitsTestFixture : public QueryFixture
|
||||
public:
|
||||
TypeTraitsTestFixture() {
|
||||
REQUIRE(db.open());
|
||||
const auto obj = matador::object::object_generator::generate<location>(repo, "location");
|
||||
const auto obj = matador::object::object_generator::generate<location>(repo.repo(), "location");
|
||||
const auto res = query::create()
|
||||
.table(obj->name())
|
||||
.columns(obj->attributes())
|
||||
|
||||
Reference in New Issue
Block a user