Compare commits

..

No commits in common. "1deaab116c196ce95aae50a38df18f07d59ff387" and "6c3af53dfa727295dd715186d32d2adb83158572" have entirely different histories.

3 changed files with 11 additions and 11 deletions

View File

@ -95,19 +95,19 @@ public:
}
template < class V >
static void on_primary_key(const char * /*id*/, V &, const utils::primary_key_attribute& /*attr*/ = utils::default_pk_attributes) {}
static void on_primary_key(const char *id, V &, const utils::primary_key_attribute& /*attr*/ = utils::default_pk_attributes) {}
static void on_revision(const char *id, uint64_t &/*rev*/);
template<typename Type>
static void on_attribute(const char * /*id*/, Type &, const utils::field_attributes &/*attr*/ = utils::null_attributes) {}
static void on_attribute(const char *id, Type &, const utils::field_attributes &/*attr*/ = utils::null_attributes) {}
template<class Pointer>
void on_belongs_to(const char * /*id*/, Pointer &obj, const utils::foreign_attributes &attr) {
void on_belongs_to(const char *id, Pointer &obj, const utils::foreign_attributes &attr) {
on_foreign_object(obj, attr);
}
template<class Pointer>
void on_has_one(const char * /*id*/, Pointer &obj, const utils::foreign_attributes &attr) {
void on_has_one(const char *id, Pointer &obj, const utils::foreign_attributes &attr) {
on_foreign_object(obj, attr);
}
template<class C>

View File

@ -164,7 +164,6 @@ statement &statement::bind(const Type &obj) {
template<class Type>
utils::result<query_result<Type>, utils::error> statement::fetch() {
std::cout << statement_proxy_->sql() << std::endl;
statement_proxy_->statement_->query_.result_type = typeid(Type);
return statement_proxy_->fetch(*bindings_).and_then([this](std::unique_ptr<query_result_impl> &&value) {
auto resolver = statement_proxy_->statement_->query_.resolver->object_resolver<Type>();
const auto prototype = value->prototype();
@ -177,7 +176,6 @@ utils::result<query_result<Type>, utils::error> statement::fetch() {
template<class Type>
utils::result<object::object_ptr<Type>, utils::error> statement::fetch_one() {
std::cout << statement_proxy_->sql() << std::endl;
statement_proxy_->statement_->query_.result_type = typeid(Type);
auto result = statement_proxy_->fetch(*bindings_);
if (!result.is_ok()) {
return utils::failure(result.err());

View File

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