moved session to namespace query and move basic_schema::initialize to session constructor
This commit is contained in:
@@ -311,7 +311,7 @@ TEST_CASE_METHOD(QueryFixture, "Select statement with foreign key and for single
|
||||
.and_then([this] {return repo.create(db); });
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
repo.initialize(db);
|
||||
// repo.initialize(db);
|
||||
|
||||
REQUIRE(db.exists(AIRPLANE.table_name()));
|
||||
REQUIRE(db.exists(FLIGHT.table_name()));
|
||||
@@ -538,7 +538,7 @@ TEST_CASE_METHOD(QueryFixture, "Test load entity with eager has many relation",
|
||||
.and_then([this] {return repo.create(db); });
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
repo.initialize(db);
|
||||
// repo.initialize(db);
|
||||
|
||||
const std::vector shipments {
|
||||
make_object<shipment>(1, "4711"),
|
||||
@@ -636,7 +636,7 @@ TEST_CASE_METHOD(QueryFixture, "Test load entity with lazy has many relation", "
|
||||
} );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
repo.initialize(db);
|
||||
// repo.initialize(db);
|
||||
|
||||
const std::vector authors {
|
||||
make_object<author>(1, "Michael", "Crichton", "23.10.1942", 1975, true),
|
||||
@@ -718,7 +718,7 @@ TEST_CASE_METHOD(QueryFixture, "Test load entity with lazy belongs to relation",
|
||||
.and_then([this] {return repo.create(db); });
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
repo.initialize(db);
|
||||
// repo.initialize(db);
|
||||
|
||||
const std::vector deps {
|
||||
make_object<department>(1, "Human Resources"),
|
||||
@@ -864,7 +864,7 @@ TEST_CASE_METHOD(QueryFixture, "Test load entity with eager has many to many rel
|
||||
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
repo.initialize(db);
|
||||
// repo.initialize(db);
|
||||
|
||||
REQUIRE(db.exists(RECIPE.table_name()));
|
||||
REQUIRE(db.exists(INGREDIENT.table_name()));
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#ifndef MATADOR_SESSION_FIXTURE_HPP
|
||||
#define MATADOR_SESSION_FIXTURE_HPP
|
||||
|
||||
#include "matador/orm/session.hpp"
|
||||
|
||||
#include "matador/utils/message_bus.hpp"
|
||||
|
||||
#include "matador/sql/connection.hpp"
|
||||
|
||||
#include "matador/query/schema.hpp"
|
||||
|
||||
namespace matador::test {
|
||||
|
||||
class SessionFixture {
|
||||
|
||||
@@ -4,10 +4,13 @@
|
||||
|
||||
#include "connection.hpp"
|
||||
|
||||
#include "matador/query/session.hpp"
|
||||
|
||||
#include "models/author.hpp"
|
||||
#include "models/book.hpp"
|
||||
|
||||
using namespace matador;
|
||||
using namespace matador::query;
|
||||
using namespace matador::object;
|
||||
using namespace matador::test;
|
||||
|
||||
@@ -58,8 +61,7 @@ TEST_CASE_METHOD(SessionFixture, "Test insert object with has many relation", "[
|
||||
.and_then([this] { return schema.create(db); } );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
orm::session ses({bus, connection::dns, 4}, schema);
|
||||
schema.initialize(ses);
|
||||
session ses({bus, connection::dns, 4}, schema);
|
||||
|
||||
auto s_king = make_object<author>(1, "Steven", "King", "21.9.1947", 1956, false);
|
||||
|
||||
@@ -79,8 +81,7 @@ TEST_CASE_METHOD(SessionFixture, "Test insert object with has many relation with
|
||||
.and_then([this] { return schema.create(db); } );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
orm::session ses({bus, connection::dns, 4}, schema);
|
||||
schema.initialize(ses);
|
||||
session ses({bus, connection::dns, 4}, schema);
|
||||
|
||||
auto s_king = make_object<author_identity>("Steven King");
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "connection.hpp"
|
||||
|
||||
#include "matador/query/session.hpp"
|
||||
|
||||
#include "models/recipe.hpp"
|
||||
#include "models/model_metas.hpp"
|
||||
|
||||
@@ -17,8 +19,7 @@ TEST_CASE_METHOD(SessionFixture, "Test insert object with has many to many relat
|
||||
.and_then( [this] { return schema.attach<ingredient>("ingredients"); } )
|
||||
.and_then([this] { return schema.create(db); } );
|
||||
|
||||
orm::session ses({bus, connection::dns, 4}, schema);
|
||||
schema.initialize(ses);
|
||||
query::session ses({bus, connection::dns, 4}, schema);
|
||||
|
||||
std::vector ingredients {
|
||||
make_object<ingredient>(1, "Apple"),
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "connection.hpp"
|
||||
|
||||
#include "matador/query/session.hpp"
|
||||
|
||||
#include "models/airplane.hpp"
|
||||
#include "models/author.hpp"
|
||||
#include "models/book.hpp"
|
||||
@@ -14,6 +16,7 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace matador;
|
||||
using namespace matador::query;
|
||||
using namespace matador::object;
|
||||
using namespace matador::test;
|
||||
|
||||
@@ -22,7 +25,7 @@ TEST_CASE_METHOD(SessionFixture, "Session insert test", "[session][insert]") {
|
||||
.and_then([this] { return schema.create(db); } );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
orm::session ses({bus, connection::dns, 4}, schema);
|
||||
session ses({bus, connection::dns, 4}, schema);
|
||||
auto plane = ses.insert(make_object<airplane>(1, "Boeing", "A380"));
|
||||
REQUIRE(plane.is_ok());
|
||||
|
||||
@@ -39,7 +42,7 @@ TEST_CASE_METHOD(SessionFixture, "Session update test", "[session][update]") {
|
||||
.and_then([this] { return schema.create(db); } );
|
||||
REQUIRE(res.is_ok());
|
||||
|
||||
orm::session ses({bus, connection::dns, 4}, schema);
|
||||
session ses({bus, connection::dns, 4}, schema);
|
||||
auto result = ses.insert(make_object<airplane>(1, "Boeing", "A380"));
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
@@ -70,9 +73,7 @@ TEST_CASE_METHOD(SessionFixture, "Session delete test", "[session][delete]") {
|
||||
.and_then([this] { return schema.create(db); } );
|
||||
REQUIRE(res.is_ok());
|
||||
|
||||
orm::session ses({bus, connection::dns, 4}, schema);
|
||||
|
||||
schema.initialize(ses);
|
||||
session ses({bus, connection::dns, 4}, schema);
|
||||
|
||||
auto result = ses.insert(make_object<airplane>(1, "Boeing", "A380"));
|
||||
REQUIRE(result.is_ok());
|
||||
@@ -87,7 +88,7 @@ TEST_CASE_METHOD(SessionFixture, "Session delete test", "[session][delete]") {
|
||||
|
||||
result = ses.find<airplane>(1);
|
||||
REQUIRE(result.is_error());
|
||||
REQUIRE(result.err().ec() == orm::error_code::FailedToFindObject);
|
||||
REQUIRE(result.err().ec() == query::error_code::FailedToFindObject);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SessionFixture, "Session relation test", "[session][relation]") {
|
||||
@@ -96,7 +97,7 @@ TEST_CASE_METHOD(SessionFixture, "Session relation test", "[session][relation]")
|
||||
.and_then([this] { return schema.create(db); } );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
orm::session ses({bus, connection::dns, 4}, schema);
|
||||
session ses({bus, connection::dns, 4}, schema);
|
||||
auto plane = ses.insert(make_object<airplane>(1, "Boeing", "A380"));
|
||||
REQUIRE(plane.is_ok());
|
||||
auto f = ses.insert(make_object<flight>(2, *plane, "sully"));
|
||||
@@ -118,13 +119,13 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find object with id", "[session
|
||||
.and_then([this] { return schema.create(db); } );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
orm::session ses({bus, connection::dns, 4}, schema);
|
||||
session ses({bus, connection::dns, 4}, schema);
|
||||
auto a380 = ses.insert(make_object<airplane>(1, "Boeing", "A380"));
|
||||
REQUIRE(a380.is_ok());
|
||||
|
||||
auto find_result = ses.find<airplane>(2);
|
||||
REQUIRE(!find_result.is_ok());
|
||||
REQUIRE((find_result.err().ec() == orm::error_code::FailedToFindObject));
|
||||
REQUIRE((find_result.err().ec() == query::error_code::FailedToFindObject));
|
||||
|
||||
find_result = ses.find<airplane>(1);
|
||||
|
||||
@@ -138,7 +139,7 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects", "[session][f
|
||||
.and_then([this] { return schema.create(db); } );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
orm::session ses({bus, connection::dns, 4}, schema);
|
||||
session ses({bus, connection::dns, 4}, schema);
|
||||
|
||||
std::vector planes {
|
||||
make_object<airplane>(1, "Airbus", "A380"),
|
||||
@@ -175,8 +176,7 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with one-to-ma
|
||||
.and_then([this] { return schema.create(db); } );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
orm::session ses({bus, connection::dns, 4}, schema);
|
||||
schema.initialize(ses);
|
||||
session ses({bus, connection::dns, 4}, schema);
|
||||
std::vector authors {
|
||||
make_object<author>(1, "Michael", "Crichton", "23.10.1942", 1975, true),
|
||||
make_object<author>( 2, "Steven", "King", "21.9.1947", 1956, false)
|
||||
@@ -230,7 +230,7 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with one-to-ma
|
||||
.and_then([this] { return schema.create(db); } );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
orm::session ses({bus, connection::dns, 4}, schema);
|
||||
session ses({bus, connection::dns, 4}, schema);
|
||||
|
||||
std::vector departments {
|
||||
make_object<department>(1, "Insurance"),
|
||||
@@ -289,7 +289,7 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with many-to-m
|
||||
return schema.create(db);
|
||||
} );
|
||||
|
||||
orm::session ses({bus, connection::dns, 4}, schema);
|
||||
session ses({bus, connection::dns, 4}, schema);
|
||||
|
||||
std::vector ingredients {
|
||||
make_object<ingredient>(1, "Apple"),
|
||||
@@ -325,7 +325,7 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with many-to-m
|
||||
return schema.create(db);
|
||||
} );
|
||||
|
||||
orm::session ses({bus, connection::dns, 4}, schema);
|
||||
session ses({bus, connection::dns, 4}, schema);
|
||||
|
||||
std::vector ingredients {
|
||||
make_object<ingredient>(1, "Apple"),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "matador/sql/connection_info.hpp"
|
||||
#include "matador/sql/connection_pool.hpp"
|
||||
#include "matador/orm/session.hpp"
|
||||
#include "matador/query/session.hpp"
|
||||
|
||||
// #include "matador/sql/statement_cache.hpp"
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
StatementTestFixture() {
|
||||
REQUIRE(repo.attach<airplane>("airplanes")
|
||||
.and_then([this] {return repo.create(db); }));
|
||||
repo.initialize(db);
|
||||
// repo.initialize(db);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user