added checks for lazy relation
This commit is contained in:
parent
4377f2fab1
commit
02d6ac514c
|
|
@ -166,8 +166,6 @@ 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]") {
|
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<book>("books")
|
auto result = schema.attach<book>("books")
|
||||||
.and_then( [this] { return schema.attach<author>("authors"); } )
|
.and_then( [this] { return schema.attach<author>("authors"); } )
|
||||||
.and_then([this] { return schema.create(db); } );
|
.and_then([this] { return schema.create(db); } );
|
||||||
|
|
@ -175,8 +173,8 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with one-to-ma
|
||||||
|
|
||||||
schema.initialize_executor(ses);
|
schema.initialize_executor(ses);
|
||||||
std::vector authors {
|
std::vector authors {
|
||||||
object_ptr{std::make_shared<author>(1, "Michael", "Crichton", "23.10.1942", 1975, true)},
|
make_object<author>(1, "Michael", "Crichton", "23.10.1942", 1975, true),
|
||||||
object_ptr{std::make_shared<author>( 2, "Steven", "King", "21.9.1947", 1956, false)}
|
make_object<author>( 2, "Steven", "King", "21.9.1947", 1956, false)
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const auto &a: authors) {
|
for (const auto &a: authors) {
|
||||||
|
|
@ -189,7 +187,7 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with one-to-ma
|
||||||
auto all_authors = find_result.release();
|
auto all_authors = find_result.release();
|
||||||
std::vector<object_ptr<author>> author_repo;
|
std::vector<object_ptr<author>> author_repo;
|
||||||
for (auto it = all_authors.begin(); it != all_authors.end(); ++it) {
|
for (auto it = all_authors.begin(); it != all_authors.end(); ++it) {
|
||||||
std::cout << "author: " << it->first_name << " (books: " << it->books.size() << ")\n";
|
REQUIRE(it->books.size() == 0);
|
||||||
author_repo.emplace_back(it.optr());
|
author_repo.emplace_back(it.optr());
|
||||||
}
|
}
|
||||||
REQUIRE(author_repo.size() == 2);
|
REQUIRE(author_repo.size() == 2);
|
||||||
|
|
@ -217,7 +215,7 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with one-to-ma
|
||||||
|
|
||||||
all_authors = find_result.release();
|
all_authors = find_result.release();
|
||||||
for (auto it = all_authors.begin(); it != all_authors.end(); ++it) {
|
for (auto it = all_authors.begin(); it != all_authors.end(); ++it) {
|
||||||
std::cout << "author: " << it->first_name << " (books: " << it->books.size() << ")\n";
|
REQUIRE(it->books.size() == 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue