diff --git a/include/matador/orm/session.hpp b/include/matador/orm/session.hpp index 822b61f..d9f1bc4 100644 --- a/include/matador/orm/session.hpp +++ b/include/matador/orm/session.hpp @@ -188,6 +188,20 @@ utils::result, utils::error> session::insert( Args&&... return insert(new Type(std::forward(args)...)); } +class update_object_binder final { +public: + explicit update_object_binder(sql::statement &stmt) + : stmt_(stmt) {} + + template < class Type > + sql::statement& bind(Type &obj) { + return stmt_; + } +private: + sql::statement &stmt_; + sql::object_pk_binder pk_binder_; +}; + template utils::result, utils::error> session::update( const object::object_ptr& obj ) { auto info = schema_->info(); @@ -206,7 +220,9 @@ utils::result, utils::error> session::update( const obj return utils::failure(res.err()); } - if (const auto update_result = res->bind(*obj).execute(); !update_result.is_ok()) { + res->bind(*obj); + update_object_binder binder(res.value());; + if (const auto update_result = binder.bind(*obj).execute(); !update_result.is_ok()) { return utils::failure(update_result.err()); } return utils::ok(object::object_ptr{obj});