has many primitive collection resolver with table and sequence
This commit is contained in:
parent
68eb2b6a6e
commit
ceb7795d9c
|
|
@ -188,7 +188,7 @@ TEST_CASE_METHOD(SessionFixture, "Test insert object with has many relation with
|
||||||
REQUIRE(author->books.size() == 5);
|
REQUIRE(author->books.size() == 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE_METHOD(SessionFixture, "Test insert object with has many primitive relation with table sequence", "[session][insert][has_many][primitive][table_sequence]") {
|
TEST_CASE_METHOD(SessionFixture, "Test insert object with has many primitive relation with identity", "[session][insert][has_many][primitive][identity]") {
|
||||||
const auto result = schema.attach<colorlist_identity>("colorlist")
|
const auto result = schema.attach<colorlist_identity>("colorlist")
|
||||||
.and_then([this] { return schema.create(db); } );
|
.and_then([this] { return schema.create(db); } );
|
||||||
REQUIRE(result.is_ok());
|
REQUIRE(result.is_ok());
|
||||||
|
|
@ -209,4 +209,50 @@ TEST_CASE_METHOD(SessionFixture, "Test insert object with has many primitive rel
|
||||||
for (const auto &cstr: clist->colors) {
|
for (const auto &cstr: clist->colors) {
|
||||||
REQUIRE(std::find(expected_colors.begin(), expected_colors.end(), cstr) != expected_colors.end());
|
REQUIRE(std::find(expected_colors.begin(), expected_colors.end(), cstr) != expected_colors.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE_METHOD(SessionFixture, "Test insert object with has many primitive relation with table sequence", "[session][insert][has_many][primitive][table_sequence]") {
|
||||||
|
const auto result = schema.attach<colorlist_table>("colorlist")
|
||||||
|
.and_then([this] { return schema.create(db); } );
|
||||||
|
REQUIRE(result.is_ok());
|
||||||
|
|
||||||
|
session ses({bus, connection::dns, 4}, schema);
|
||||||
|
|
||||||
|
const auto c = make_object<colorlist_table>("rgb", std::vector<std::string>{"red", "green", "blue"});
|
||||||
|
|
||||||
|
auto res = ses.insert(c);
|
||||||
|
REQUIRE(res.is_ok());
|
||||||
|
|
||||||
|
auto colorlist_result = ses.find<colorlist_table>(c->id);
|
||||||
|
REQUIRE(colorlist_result);
|
||||||
|
auto clist = *colorlist_result;
|
||||||
|
REQUIRE(clist.is_persistent());
|
||||||
|
REQUIRE(clist->colors.size() == 3);
|
||||||
|
std::vector<std::string> expected_colors{"red", "green", "blue"};
|
||||||
|
for (const auto &cstr: clist->colors) {
|
||||||
|
REQUIRE(std::find(expected_colors.begin(), expected_colors.end(), cstr) != expected_colors.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE_METHOD(SessionFixture, "Test insert object with has many primitive relation with sequence", "[session][insert][has_many][primitive][sequence]") {
|
||||||
|
const auto result = schema.attach<colorlist_sequence>("colorlist")
|
||||||
|
.and_then([this] { return schema.create(db); } );
|
||||||
|
REQUIRE(result.is_ok());
|
||||||
|
|
||||||
|
session ses({bus, connection::dns, 4}, schema);
|
||||||
|
|
||||||
|
const auto c = make_object<colorlist_sequence>("rgb", std::vector<std::string>{"red", "green", "blue"});
|
||||||
|
|
||||||
|
auto res = ses.insert(c);
|
||||||
|
REQUIRE(res.is_ok());
|
||||||
|
|
||||||
|
auto colorlist_result = ses.find<colorlist_sequence>(c->id);
|
||||||
|
REQUIRE(colorlist_result);
|
||||||
|
auto clist = *colorlist_result;
|
||||||
|
REQUIRE(clist.is_persistent());
|
||||||
|
REQUIRE(clist->colors.size() == 3);
|
||||||
|
std::vector<std::string> expected_colors{"red", "green", "blue"};
|
||||||
|
for (const auto &cstr: clist->colors) {
|
||||||
|
REQUIRE(std::find(expected_colors.begin(), expected_colors.end(), cstr) != expected_colors.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue