session and insert query builder progress
This commit is contained in:
@@ -5,10 +5,12 @@
|
||||
#include "connection.hpp"
|
||||
|
||||
#include "models/recipe.hpp"
|
||||
#include "models/model_metas.hpp"
|
||||
|
||||
using namespace matador;
|
||||
using namespace matador::object;
|
||||
using namespace matador::test;
|
||||
using namespace matador::query::meta;
|
||||
|
||||
TEST_CASE_METHOD(SessionFixture, "Test insert object with has many to many relation", "[session][insert][has_many_to_many]") {
|
||||
auto result = schema.attach<recipe>("recipes")
|
||||
@@ -16,6 +18,7 @@ TEST_CASE_METHOD(SessionFixture, "Test insert object with has many to many relat
|
||||
.and_then([this] { return schema.create(db); } );
|
||||
|
||||
orm::session ses({bus, connection::dns, 4}, schema);
|
||||
schema.initialize(ses);
|
||||
|
||||
std::vector ingredients {
|
||||
make_object<ingredient>(1, "Apple"),
|
||||
@@ -37,4 +40,16 @@ TEST_CASE_METHOD(SessionFixture, "Test insert object with has many to many relat
|
||||
auto res = ses.insert(r);
|
||||
REQUIRE(res.is_ok());
|
||||
}
|
||||
|
||||
auto recipe_result = ses.find<recipe>(1);
|
||||
// auto recipe_result = ses.find<recipe>(RECIPE.id == 1);
|
||||
REQUIRE(recipe_result.is_ok());
|
||||
|
||||
// auto r = *recipe_result->begin();
|
||||
auto r = *recipe_result;
|
||||
std::cout << r->name << " (ingredients: " << r->ingredients.size() << ")" << std::endl;
|
||||
// REQUIRE(r->name != "");
|
||||
for (const auto &ingr: r->ingredients) {
|
||||
std::cout << " " << ingr->name << std::endl;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user