added update_object_binder progress
This commit is contained in:
@@ -190,15 +190,48 @@ utils::result<object::object_ptr<Type>, utils::error> session::insert( Args&&...
|
||||
|
||||
class update_object_binder final {
|
||||
public:
|
||||
explicit update_object_binder(sql::statement &stmt)
|
||||
: stmt_(stmt) {}
|
||||
explicit update_object_binder(sql::statement &stmt, size_t position)
|
||||
: stmt_(stmt)
|
||||
, binding_position_(position){}
|
||||
|
||||
template < class Type >
|
||||
sql::statement& bind(Type &obj) {
|
||||
access::process(*this, obj);
|
||||
return stmt_;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void on_primary_key(const char * /*id*/, Type &x, const utils::primary_key_attribute& /*attr*/ = utils::default_pk_attributes) {
|
||||
stmt_.bind(binding_position_, x);
|
||||
}
|
||||
|
||||
static void on_revision(const char * /*id*/, uint64_t &/*rev*/) {}
|
||||
template < class Type >
|
||||
static void on_attribute(const char * /*id*/, Type &/*x*/, const utils::field_attributes &/*attr*/ = utils::null_attributes) {}
|
||||
template < class Pointer >
|
||||
static void on_belongs_to(const char * /*id*/, Pointer &/*x*/, const utils::foreign_attributes &/*attr*/ = utils::default_foreign_attributes) {}
|
||||
template < class Pointer >
|
||||
static void on_has_one(const char * /*id*/, Pointer &/*x*/, const utils::foreign_attributes &/*attr*/ = utils::default_foreign_attributes) {}
|
||||
|
||||
template<class ContainerType>
|
||||
static void on_has_many(const char * /*id*/,
|
||||
ContainerType &/*c*/,
|
||||
const char * /*join_column*/,
|
||||
const utils::foreign_attributes &/*attr*/ = utils::default_foreign_attributes) {}
|
||||
template<class ContainerType>
|
||||
static void on_has_many_to_many(const char * /*id*/,
|
||||
ContainerType &/*c*/,
|
||||
const char * /*join_column*/,
|
||||
const char * /*inverse_join_column*/,
|
||||
const utils::foreign_attributes &/*attr*/) {}
|
||||
template<class ContainerType>
|
||||
static void on_has_many_to_many(const char * /*id*/,
|
||||
ContainerType &/*c*/,
|
||||
const utils::foreign_attributes &/*attr*/) {}
|
||||
|
||||
private:
|
||||
sql::statement &stmt_;
|
||||
size_t binding_position_{0};
|
||||
sql::object_pk_binder pk_binder_;
|
||||
};
|
||||
|
||||
@@ -221,7 +254,7 @@ utils::result<object::object_ptr<Type>, utils::error> session::update( const obj
|
||||
}
|
||||
|
||||
res->bind(*obj);
|
||||
update_object_binder binder(res.value());;
|
||||
update_object_binder binder(res.value(), res->bind_pos());
|
||||
if (const auto update_result = binder.bind(*obj).execute(); !update_result.is_ok()) {
|
||||
return utils::failure(update_result.err());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user