collection resolver progress
This commit is contained in:
@@ -588,10 +588,8 @@ TEST_CASE_METHOD(QueryFixture, "Test load entity with eager has many relation",
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(QueryFixture, "Test load entity with lazy has many relation", "[query][has_many][lazy]") {
|
||||
// auto result = repo.attach<author>("authors")
|
||||
// .and_then( [this] { return repo.attach<book>("books"); } )
|
||||
auto result = repo.attach<book>("books")
|
||||
.and_then( [this] { return repo.attach<author>("authors"); } )
|
||||
auto result = repo.attach<author>("authors")
|
||||
.and_then( [this] { return repo.attach<book>("books"); } )
|
||||
.and_then([this] {
|
||||
return repo.create(db);
|
||||
} );
|
||||
@@ -662,6 +660,13 @@ TEST_CASE_METHOD(QueryFixture, "Test load entity with lazy has many relation", "
|
||||
REQUIRE(a->year_of_birth == authors.at(index)->year_of_birth);
|
||||
REQUIRE(a->distinguished == authors.at(index)->distinguished);
|
||||
REQUIRE(!a->books.empty());
|
||||
for (const auto& b : a->books) {
|
||||
const auto title = b->title;
|
||||
// REQUIRE(b->id == books.at(index)->id);
|
||||
// REQUIRE(b->title == books.at(index)->title);
|
||||
// REQUIRE(b->author_id == books.at(index)->author_id);
|
||||
// REQUIRE(b->published_in == books.at(index)->published_in);
|
||||
}
|
||||
++index;
|
||||
}
|
||||
}
|
||||
@@ -735,11 +740,12 @@ TEST_CASE_METHOD(QueryFixture, "Test load entity with lazy belongs to relation",
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(QueryFixture, "Test load entity with eager belongs to relation", "[query][belongs_to][eager]") {
|
||||
auto result = repo.attach<author>("authors")
|
||||
.and_then( [this] { return repo.attach<book>("books"); } )
|
||||
.and_then([this] {
|
||||
return repo.create(db);
|
||||
} );
|
||||
// auto result = repo.attach<author>("authors")
|
||||
// .and_then( [this] { return repo.attach<book>("books"); } )
|
||||
auto result = repo.attach<book>("books")
|
||||
.and_then( [this] { return repo.attach<author>("authors"); })
|
||||
.and_then([this] { return repo.create(db); });
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
const std::vector authors {
|
||||
object_ptr{std::make_shared<author>(1, "Michael", "Crichton", "23.10.1942", 1975, true)},
|
||||
|
||||
@@ -17,8 +17,10 @@ TEST_CASE_METHOD(SchemaFixture, "Test schema one-two-many", "[schema][one-to-man
|
||||
using namespace matador::test;
|
||||
query::schema repo;
|
||||
|
||||
auto result = repo.attach<department>("departments")
|
||||
.and_then([&repo] { return repo.attach<employee>("employees"); });
|
||||
// auto result = repo.attach<department>("departments")
|
||||
// .and_then([&repo] { return repo.attach<employee>("employees"); });
|
||||
auto result = repo.attach<employee>("employees")
|
||||
.and_then([&repo] { return repo.attach<department>("departments"); });
|
||||
REQUIRE(result);
|
||||
|
||||
auto conn = pool.acquire();
|
||||
|
||||
@@ -165,9 +165,12 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects", "[session][f
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with one-to-many lazy relation", "[session][find][one-to-many][eager]") {
|
||||
auto result = schema.attach<author>("authors")
|
||||
.and_then( [this] { return schema.attach<book>("books"); } )
|
||||
// auto result = schema.attach<author>("authors")
|
||||
// .and_then( [this] { return schema.attach<book>("books"); } )
|
||||
auto result = schema.attach<book>("books")
|
||||
.and_then( [this] { return schema.attach<author>("authors"); } )
|
||||
.and_then([this] { return schema.create(db); } );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
schema.initialize_executor(ses);
|
||||
std::vector authors {
|
||||
@@ -217,11 +220,14 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with one-to-ma
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with one-to-many eager relation", "[session][find][one-to-many][eager]") {
|
||||
auto result = schema.attach<department>("departments")
|
||||
.and_then( [this] { return schema.attach<employee>("employees"); } )
|
||||
// auto result = repo.attach<department>("departments")
|
||||
// .and_then([this] { return repo.attach<employee>("employees"); })
|
||||
auto result = schema.attach<employee>("employees")
|
||||
.and_then([this] { return schema.attach<department>("departments"); })
|
||||
.and_then([this] {
|
||||
return schema.create(db);
|
||||
} );
|
||||
REQUIRE(result.is_ok());
|
||||
|
||||
std::vector<std::unique_ptr<department>> departments;
|
||||
departments.emplace_back(new department{1, "Insurance"});
|
||||
|
||||
Reference in New Issue
Block a user