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())
|
||||
|
||||
@@ -75,16 +75,6 @@ TEST_CASE("Test next and previous of schema node", "[schema_node][next][previous
|
||||
REQUIRE(++it == repo.end());
|
||||
}
|
||||
|
||||
TEST_CASE("Test automatic creating of a relation table with foreign key", "[schema][relation_table][foreign_key]") {
|
||||
object::repository repo;
|
||||
|
||||
REQUIRE(repo.empty());
|
||||
|
||||
auto res = repo.attach<test::department>("department");
|
||||
REQUIRE(res.is_ok());
|
||||
REQUIRE(repo.size() == 2);
|
||||
}
|
||||
|
||||
TEST_CASE("Test automatic creating of a relation table with values", "[schema][relation_table][values]") {
|
||||
object::repository repo;
|
||||
|
||||
@@ -175,22 +165,13 @@ TEST_CASE("Test many to many relation", "[relation][many-to-many]") {
|
||||
template<typename Type>
|
||||
class test_observer : public matador::object::observer<Type> {
|
||||
public:
|
||||
void on_attach(object::repository_node& node, const Type& prototype) override {
|
||||
int i = 0;
|
||||
}
|
||||
void on_detach(object::repository_node& node, const Type& prototype) override {
|
||||
|
||||
}
|
||||
void on_insert(Type& obj) override {
|
||||
|
||||
}
|
||||
void on_update(Type& obj) override {
|
||||
|
||||
}
|
||||
void on_delete(Type& obj) override {
|
||||
|
||||
}
|
||||
void on_attach(const object::repository_node& /*node*/, const Type& /*prototype*/) const override {}
|
||||
void on_detach(const object::repository_node& /*node*/, const Type& /*prototype*/) const override {}
|
||||
void on_insert(const Type& /*obj*/) override {}
|
||||
void on_update(const Type& /*obj*/) override {}
|
||||
void on_delete(const Type& /*obj*/) override {}
|
||||
};
|
||||
|
||||
TEST_CASE("Test repository observer", "[repository][observer]") {
|
||||
object::repository repo;
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include "matador/query/table.hpp"
|
||||
#include "matador/query/schema.hpp"
|
||||
|
||||
#include "matador/utils/macro_map.hpp"
|
||||
|
||||
#include "matador/orm/session_query_builder.hpp"
|
||||
|
||||
#include "../backend/test_connection.hpp"
|
||||
@@ -33,26 +35,63 @@ using namespace matador::utils;
|
||||
using namespace matador::sql;
|
||||
using namespace matador::test;
|
||||
|
||||
// #define FIELD(FIELD_NAME) const matador::query::column& FIELD_NAME = create_column(*this, #FIELD_NAME);
|
||||
//
|
||||
// #define META_TABLE(TABLE_NAME, VARIABLE_NAME, ...) \
|
||||
// namespace matador::query::meta { \
|
||||
// namespace internal { \
|
||||
// class TABLE_NAME##_table : public table { \
|
||||
// public: \
|
||||
// TABLE_NAME##_table() : table(#TABLE_NAME) {} \
|
||||
// MAP(FIELD, __VA_ARGS__) \
|
||||
// }; } \
|
||||
// static const internal:: TABLE_NAME##_table VARIABLE_NAME; \
|
||||
// }
|
||||
//
|
||||
// META_TABLE( books, BOOK, id, author_id, title, published_in )
|
||||
|
||||
class book_table : public table {
|
||||
public:
|
||||
book_table()
|
||||
: table("books", {"id", "title", "author_id"})
|
||||
, id(*column_by_name(*this, "id"))
|
||||
, title(*column_by_name(*this, "id"))
|
||||
, author_id(*column_by_name(*this, "author_id")) {
|
||||
}
|
||||
|
||||
const column& id;
|
||||
const column& title;
|
||||
const column& author_id;
|
||||
};
|
||||
|
||||
book_table BOOK;
|
||||
|
||||
using namespace matador::test;
|
||||
|
||||
TEST_CASE("Create sql query data for entity with eager has one", "[query][entity][builder]") {
|
||||
using namespace matador::test;
|
||||
backend_provider::instance().register_backend("noop", std::make_unique<orm::test_backend_service>());
|
||||
connection db("noop://noop.db");
|
||||
connection_pool pool("noop://noop.db", 4);
|
||||
|
||||
schema scm(pool);
|
||||
schema scm;
|
||||
auto result = scm.attach<airplane>("airplanes")
|
||||
.and_then( [&scm] { return scm.attach<flight>("flights"); } );
|
||||
REQUIRE(result);
|
||||
|
||||
session_query_builder eqb(scm, db);
|
||||
|
||||
auto data = eqb.build<flight>("flights.id"_col == _);
|
||||
const auto it = scm.find(typeid(flight));
|
||||
REQUIRE(it != scm.end());
|
||||
const auto* col = it->second.table()["id"];
|
||||
REQUIRE(col);
|
||||
auto data = eqb.build<flight>(*col == _);
|
||||
|
||||
REQUIRE(data.is_ok());
|
||||
REQUIRE(data->root_table->name() == "flights");
|
||||
REQUIRE(data->root_table->table_name() == "flights");
|
||||
REQUIRE(data->joins.size() == 1);
|
||||
const auto flights = table("flights");
|
||||
const auto airplanes = table("airplanes");
|
||||
const auto flights = table("flights").as("t01");
|
||||
const auto airplanes = table("airplanes").as("t02");
|
||||
const std::vector<column> expected_columns {
|
||||
{ &flights, "id", "c01" },
|
||||
{ &airplanes, "id", "c02" },
|
||||
@@ -73,7 +112,7 @@ TEST_CASE("Create sql query data for entity with eager has one", "[query][entity
|
||||
size_t index{0};
|
||||
criteria_evaluator evaluator(db.dialect(), qc);
|
||||
for (const auto &[join_table, condition] : data->joins) {
|
||||
REQUIRE(join_table->name() == expected_join_data[index].first);
|
||||
REQUIRE(join_table->table_name() == expected_join_data[index].first);
|
||||
REQUIRE(evaluator.evaluate(*condition) == expected_join_data[index].second);
|
||||
++index;
|
||||
}
|
||||
@@ -89,20 +128,24 @@ TEST_CASE("Create sql query data for entity with eager belongs to", "[query][ent
|
||||
connection db("noop://noop.db");
|
||||
connection_pool pool("noop://noop.db", 4);
|
||||
|
||||
schema scm(pool);
|
||||
schema scm;
|
||||
auto result = scm.attach<author>("authors")
|
||||
.and_then( [&scm] { return scm.attach<book>("books"); } );
|
||||
REQUIRE(result);
|
||||
|
||||
session_query_builder eqb(scm, db);
|
||||
|
||||
auto data = eqb.build<book>("books.id"_col == _);
|
||||
const auto it = scm.find(typeid(book));
|
||||
REQUIRE(it != scm.end());
|
||||
const auto* col = it->second.table()["id"];
|
||||
REQUIRE(col);
|
||||
auto data = eqb.build<book>(*col == _);
|
||||
|
||||
REQUIRE(data.is_ok());
|
||||
REQUIRE(data->root_table->name() == "books");
|
||||
REQUIRE(data->root_table->table_name() == "books");
|
||||
REQUIRE(data->joins.size() == 1);
|
||||
const auto books = table("books");
|
||||
const auto authors = table("authors");
|
||||
const auto books = table("books").as("t01");
|
||||
const auto authors = table("authors").as("t02");
|
||||
const std::vector<column> expected_columns {
|
||||
{ &books, "id", "c01" },
|
||||
{ &books, "title", "c02" },
|
||||
@@ -127,7 +170,7 @@ TEST_CASE("Create sql query data for entity with eager belongs to", "[query][ent
|
||||
size_t index{0};
|
||||
criteria_evaluator evaluator(db.dialect(), qc);
|
||||
for (const auto & [join_table, clause] : data->joins) {
|
||||
REQUIRE(join_table->name() == expected_join_data[index].first);
|
||||
REQUIRE(join_table->table_name() == expected_join_data[index].first);
|
||||
REQUIRE(evaluator.evaluate(*clause) == expected_join_data[index].second);
|
||||
++index;
|
||||
}
|
||||
@@ -154,7 +197,7 @@ TEST_CASE("Create sql query data for entity with eager has many belongs to", "[q
|
||||
connection db("noop://noop.db");
|
||||
connection_pool pool("noop://noop.db", 4);
|
||||
|
||||
schema scm(pool);
|
||||
schema scm;
|
||||
auto result = scm.attach<product>("products")
|
||||
.and_then( [&scm] { return scm.attach<order_details>("order_details"); } )
|
||||
.and_then( [&scm] { return scm.attach<supplier>("suppliers"); } )
|
||||
@@ -164,13 +207,17 @@ TEST_CASE("Create sql query data for entity with eager has many belongs to", "[q
|
||||
|
||||
session_query_builder eqb(scm, db);
|
||||
|
||||
auto data = eqb.build<order>("orders.order_id"_col == _);
|
||||
const auto it = scm.find(typeid(order));
|
||||
REQUIRE(it != scm.end());
|
||||
const auto* col = it->second.table()["order_id"];
|
||||
REQUIRE(col);
|
||||
auto data = eqb.build<order>(*col == _);
|
||||
|
||||
REQUIRE(data.is_ok());
|
||||
REQUIRE(data->root_table->name() == "orders");
|
||||
REQUIRE(data->root_table->table_name() == "orders");
|
||||
REQUIRE(data->joins.size() == 1);
|
||||
const auto orders = table("orders");
|
||||
const auto order_details = table("order_details");
|
||||
const auto orders = table("orders").as("t01");
|
||||
const auto order_details = table("order_details").as("t02");
|
||||
const std::vector<column> expected_columns = {
|
||||
{ &orders, "order_id", "c01" },
|
||||
{ &orders, "order_date", "c02" },
|
||||
@@ -201,7 +248,7 @@ TEST_CASE("Create sql query data for entity with eager has many belongs to", "[q
|
||||
size_t index{0};
|
||||
criteria_evaluator evaluator(db.dialect(), qc);
|
||||
for (const auto &jd : data->joins) {
|
||||
REQUIRE(jd.join_table->name() == expected_join_data[index].first);
|
||||
REQUIRE(jd.join_table->table_name() == expected_join_data[index].first);
|
||||
REQUIRE(evaluator.evaluate(*jd.condition) == expected_join_data[index].second);
|
||||
++index;
|
||||
}
|
||||
@@ -217,20 +264,24 @@ TEST_CASE("Create sql query data for entity with eager many to many", "[query][e
|
||||
connection db("noop://noop.db");
|
||||
connection_pool pool("noop://noop.db", 4);
|
||||
|
||||
schema scm(pool);
|
||||
schema scm;
|
||||
auto result = scm.attach<recipe>("recipes")
|
||||
.and_then( [&scm] { return scm.attach<ingredient>("ingredients"); } );
|
||||
REQUIRE(result);
|
||||
|
||||
session_query_builder eqb(scm, db);
|
||||
|
||||
auto data = eqb.build<ingredient>("ingredients.id"_col == _);
|
||||
const auto it = scm.find(typeid(ingredient));
|
||||
REQUIRE(it != scm.end());
|
||||
const auto* col = it->second.table()["id"];
|
||||
REQUIRE(col);
|
||||
auto data = eqb.build<ingredient>(*col == _);
|
||||
|
||||
REQUIRE(data.is_ok());
|
||||
REQUIRE(data->root_table->name() == "ingredients");
|
||||
REQUIRE(data->root_table->table_name() == "ingredients");
|
||||
REQUIRE(data->joins.size() == 2);
|
||||
const auto ingredients = table("ingredients");
|
||||
const auto recipes = table("recipes");
|
||||
const auto ingredients = table("ingredients").as("t01");
|
||||
const auto recipes = table("recipes").as("t03");
|
||||
const std::vector<column> expected_columns {
|
||||
{ &ingredients, "id", "c01" },
|
||||
{ &ingredients, "name", "c02" },
|
||||
@@ -251,7 +302,7 @@ TEST_CASE("Create sql query data for entity with eager many to many", "[query][e
|
||||
size_t index{0};
|
||||
criteria_evaluator evaluator(db.dialect(), qc);
|
||||
for (const auto &jd : data->joins) {
|
||||
REQUIRE(jd.join_table->name() == expected_join_data[index].first);
|
||||
REQUIRE(jd.join_table->table_name() == expected_join_data[index].first);
|
||||
REQUIRE(evaluator.evaluate(*jd.condition) == expected_join_data[index].second);
|
||||
++index;
|
||||
}
|
||||
@@ -267,20 +318,24 @@ TEST_CASE("Create sql query data for entity with eager many to many (inverse par
|
||||
connection db("noop://noop.db");
|
||||
connection_pool pool("noop://noop.db", 4);
|
||||
|
||||
schema scm(pool);
|
||||
schema scm;
|
||||
auto result = scm.attach<student>("students")
|
||||
.and_then( [&scm] { return scm.attach<course>("courses"); } );
|
||||
REQUIRE(result);
|
||||
|
||||
session_query_builder eqb(scm, db);
|
||||
|
||||
auto data = eqb.build<course>("courses.id"_col == _);
|
||||
const auto it = scm.find(typeid(course));
|
||||
REQUIRE(it != scm.end());
|
||||
const auto* col = it->second.table()["id"];
|
||||
REQUIRE(col);
|
||||
auto data = eqb.build<course>(*col == _);
|
||||
|
||||
REQUIRE(data.is_ok());
|
||||
REQUIRE(data->root_table->name() == "courses");
|
||||
REQUIRE(data->root_table->table_name() == "courses");
|
||||
REQUIRE(data->joins.size() == 2);
|
||||
const auto courses = table("courses");
|
||||
const auto students = table("students");
|
||||
const auto courses = table("courses").as("t01");
|
||||
const auto students = table("students").as("t03");
|
||||
const std::vector<column> expected_columns {
|
||||
{ &courses, "id", "c01" },
|
||||
{ &courses, "title", "c02" },
|
||||
@@ -301,7 +356,7 @@ TEST_CASE("Create sql query data for entity with eager many to many (inverse par
|
||||
size_t index{0};
|
||||
criteria_evaluator evaluator(db.dialect(), qc);
|
||||
for (const auto &jd : data->joins) {
|
||||
REQUIRE(jd.join_table->name() == expected_join_data[index].first);
|
||||
REQUIRE(jd.join_table->table_name() == expected_join_data[index].first);
|
||||
REQUIRE(evaluator.evaluate(*jd.condition) == expected_join_data[index].second);
|
||||
++index;
|
||||
}
|
||||
@@ -317,7 +372,7 @@ TEST_CASE("Test eager relationship", "[session][eager]") {
|
||||
connection db("noop://noop.db");
|
||||
connection_pool pool("noop://noop.db", 4);
|
||||
|
||||
schema scm(pool);
|
||||
schema scm;
|
||||
auto result = scm.attach<department>("departments")
|
||||
.and_then( [&scm] { return scm.attach<employee>("employees"); } );
|
||||
REQUIRE(result);
|
||||
@@ -331,7 +386,7 @@ TEST_CASE("Test eager relationship", "[session][eager]") {
|
||||
.from(*data->root_table)
|
||||
.join_left(data->joins)
|
||||
.where(std::move(data->where_clause))
|
||||
.order_by(column{data->root_table.get(), data->pk_column_name})
|
||||
.order_by(column{data->root_table, data->pk_column_name})
|
||||
.asc()
|
||||
.str(db);
|
||||
|
||||
|
||||
@@ -32,18 +32,18 @@ TEST_CASE("Test column value generator", "[generator][column_value]") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Test column generator", "[generator][column]") {
|
||||
SECTION("Test column generator for simple table") {
|
||||
const std::vector expected_columns {
|
||||
column("id"),
|
||||
column("brand"),
|
||||
column("model"),
|
||||
};
|
||||
const auto result = generator::columns<airplane>();
|
||||
REQUIRE(result.size() == expected_columns.size());
|
||||
auto it = result.begin();
|
||||
for (const auto& c : expected_columns) {
|
||||
REQUIRE(c.equals( *it++));
|
||||
}
|
||||
}
|
||||
}
|
||||
// TEST_CASE("Test column generator", "[generator][column]") {
|
||||
// SECTION("Test column generator for simple table") {
|
||||
// const std::vector expected_columns {
|
||||
// column("id"),
|
||||
// column("brand"),
|
||||
// column("model"),
|
||||
// };
|
||||
// const auto result = generator::columns<airplane>();
|
||||
// REQUIRE(result.size() == expected_columns.size());
|
||||
// auto it = result.begin();
|
||||
// for (const auto& c : expected_columns) {
|
||||
// REQUIRE(c.equals( *it++));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -39,9 +39,9 @@ TEST_CASE_METHOD(QueryFixture, "Test create table sql statement string", "[query
|
||||
auto result = 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"})
|
||||
@@ -53,10 +53,10 @@ TEST_CASE_METHOD(QueryFixture, "Test create table sql statement string", "[query
|
||||
auto ctx = query::create()
|
||||
.table("person")
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("name", basic_type::Varchar, {255, constraints::Unique}),
|
||||
attribute("age", basic_type::UInt16),
|
||||
attribute("address", basic_type::UInt32)
|
||||
column("id", basic_type::UInt32),
|
||||
column("name", basic_type::Varchar, 255).unique(),
|
||||
column("age", basic_type::UInt16),
|
||||
column("address", basic_type::UInt32)
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_person").primary_key({"id"}),
|
||||
@@ -221,9 +221,9 @@ TEST_CASE_METHOD(QueryFixture, "Test create, insert and select a blob column", "
|
||||
auto result = query::create()
|
||||
.table("person")
|
||||
.columns({
|
||||
attribute("id", basic_type::UInt32),
|
||||
attribute("name", basic_type::Varchar, 255),
|
||||
attribute("data", basic_type::Blob)
|
||||
column("id", basic_type::UInt32),
|
||||
column("name", basic_type::Varchar, 255),
|
||||
column("data", basic_type::Blob)
|
||||
})
|
||||
.constraints({
|
||||
constraint("PK_person").primary_key({"id"})
|
||||
@@ -247,10 +247,14 @@ TEST_CASE_METHOD(QueryFixture, "Test create, insert and select a blob column", "
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(QueryFixture, "Test select statement with join_left", "[query][statement][join_left]") {
|
||||
const auto ap = table("airplane").as("ap");
|
||||
const auto f = table("flight").as("f");
|
||||
const class matador::query::column col1 = {&f, "airplane_id"};
|
||||
const class matador::query::column col2 = {&ap, "id"};
|
||||
const auto result = query::select({"f.id", "ap.brand", "f.pilot_name"})
|
||||
.from({"flight", "f"})
|
||||
.join_left({"airplane", "ap"})
|
||||
.on("f.airplane_id"_col == "ap.id"_col)
|
||||
.from(table{"flight"}.as("f"))
|
||||
.join_left(table{"airplane"}.as("ap"))
|
||||
.on(col1 == col2)
|
||||
.str(*db);
|
||||
|
||||
REQUIRE(result == R"(SELECT "f"."id", "ap"."brand", "f"."pilot_name" FROM "flight" "f" LEFT JOIN "airplane" "ap" ON "f"."airplane_id" = "ap"."id")");
|
||||
|
||||
@@ -26,7 +26,7 @@ TEST_CASE("Generate columns from object", "[column][generator]") {
|
||||
backend_provider::instance().register_backend("noop", std::make_unique<orm::test_backend_service>());
|
||||
connection_pool pool("noop://noop.db", 4);
|
||||
|
||||
schema s(pool);
|
||||
schema s;
|
||||
auto result = s.attach<product>("product");
|
||||
REQUIRE( result );
|
||||
|
||||
@@ -56,7 +56,7 @@ TEST_CASE("Generate columns for object with has many relation", "[column][genera
|
||||
backend_provider::instance().register_backend("noop", std::make_unique<orm::test_backend_service>());
|
||||
connection_pool pool("noop://noop.db", 4);
|
||||
|
||||
schema s(pool);
|
||||
schema s;
|
||||
auto result = s.attach<supplier>("supplier")
|
||||
.and_then( [&s] { return s.attach<category>("categories"); } )
|
||||
.and_then( [&s] { return s.attach<order_details>("order_details"); } )
|
||||
@@ -99,7 +99,7 @@ TEST_CASE("Generate columns for object with eager foreign key relation", "[colum
|
||||
backend_provider::instance().register_backend("noop", std::make_unique<orm::test_backend_service>());
|
||||
connection_pool pool("noop://noop.db", 4);
|
||||
|
||||
schema s(pool);
|
||||
schema s;
|
||||
auto result = s.attach<book>("books")
|
||||
.and_then( [&s] { return s.attach<author>("authors"); } );
|
||||
REQUIRE(result);
|
||||
|
||||
Reference in New Issue
Block a user