diff options
Diffstat (limited to 'odb/mssql/no-id-object-result.txx')
-rw-r--r-- | odb/mssql/no-id-object-result.txx | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/odb/mssql/no-id-object-result.txx b/odb/mssql/no-id-object-result.txx index c7e9914..bed98ac 100644 --- a/odb/mssql/no-id-object-result.txx +++ b/odb/mssql/no-id-object-result.txx @@ -16,18 +16,31 @@ namespace odb no_id_object_result_impl<T>:: ~no_id_object_result_impl () { + invalidate (); + } + + template <typename T> + void no_id_object_result_impl<T>:: + invalidate () + { change_callback_type& cc (statements_.image ().change_callback_); if (cc.context == this) { - cc.context = 0; cc.callback = 0; + cc.context = 0; } + delete image_copy_; + image_copy_ = 0; + if (!this->end_) + { statement_->free_result (); + this->end_ = true; + } - delete image_copy_; + statement_.reset (); } template <typename T> @@ -35,7 +48,7 @@ namespace odb no_id_object_result_impl (const query_base&, details::shared_ptr<select_statement> statement, statements_type& statements) - : base_type (statements.connection ().database ()), + : base_type (statements.connection ()), statement_ (statement), statements_ (statements), use_copy_ (false), @@ -50,13 +63,11 @@ namespace odb if (!can_load_) throw long_data_reload (); - odb::database& db (this->database ()); - - object_traits::callback (db, obj, callback_event::pre_load); + object_traits::callback (this->db_, obj, callback_event::pre_load); object_traits::init (obj, use_copy_ ? *image_copy_ : statements_.image (), - &db); + &this->db_); // If we are using a copy, make sure the callback information for // long data also comes from the copy. @@ -65,7 +76,7 @@ namespace odb use_copy_ ? &statements_.image () : 0, use_copy_ ? image_copy_ : 0); - object_traits::callback (db, obj, callback_event::post_load); + object_traits::callback (this->db_, obj, callback_event::post_load); } template <typename T> |