aboutsummaryrefslogtreecommitdiff
path: root/odb/mssql/polymorphic-object-result.txx
diff options
context:
space:
mode:
Diffstat (limited to 'odb/mssql/polymorphic-object-result.txx')
-rw-r--r--odb/mssql/polymorphic-object-result.txx26
1 files changed, 19 insertions, 7 deletions
diff --git a/odb/mssql/polymorphic-object-result.txx b/odb/mssql/polymorphic-object-result.txx
index e469511..53244a3 100644
--- a/odb/mssql/polymorphic-object-result.txx
+++ b/odb/mssql/polymorphic-object-result.txx
@@ -18,6 +18,13 @@ namespace odb
polymorphic_object_result_impl<T>::
~polymorphic_object_result_impl ()
{
+ invalidate ();
+ }
+
+ template <typename T>
+ void polymorphic_object_result_impl<T>::
+ invalidate ()
+ {
change_callback_type& cc (
statements_.root_statements ().image ().change_callback_);
@@ -28,10 +35,15 @@ namespace odb
}
if (image_copy_ != 0)
+ {
object_traits::free_image (image_copy_);
+ image_copy_ = 0;
+ }
if (!this->end_)
statement_->free_result ();
+
+ statement_.reset ();
}
template <typename T>
@@ -39,7 +51,7 @@ namespace odb
polymorphic_object_result_impl (const query_base&,
details::shared_ptr<select_statement> st,
statements_type& sts)
- : base_type (sts.connection ().database ()),
+ : base_type (sts.connection ()),
statement_ (st),
statements_ (sts),
use_copy_ (false),
@@ -62,7 +74,6 @@ namespace odb
assert (!rsts.locked ());
typename statements_type::auto_lock l (rsts);
- odb::database& db (this->database ());
image_type& i (use_copy_ ? *image_copy_ : statements_.image ());
typename root_traits::image_type& ri (
use_copy_ ? object_traits::root_image (i) : rsts.image ());
@@ -99,7 +110,8 @@ namespace odb
// Insert it as a root pointer (for non-unique pointers, rp should
// still be valid and for unique pointers this is a no-op).
//
- ig.reset (object_traits::pointer_cache_traits::insert (db, id, rp));
+ ig.reset (
+ object_traits::pointer_cache_traits::insert (this->db_, id, rp));
pobj = &pointer_traits::get_ref (p);
current (p);
@@ -120,9 +132,9 @@ namespace odb
}
callback_event ce (callback_event::pre_load);
- pi.dispatch (info_type::call_callback, db, pobj, &ce);
+ pi.dispatch (info_type::call_callback, this->db_, pobj, &ce);
- object_traits::init (*pobj, i, &db);
+ object_traits::init (*pobj, i, &this->db_);
// If we are using a copy, make sure the callback information for
// long data also comes from the copy.
@@ -153,14 +165,14 @@ namespace odb
if (&pi != &object_traits::info)
{
std::size_t d (object_traits::depth);
- pi.dispatch (info_type::call_load, db, pobj, &d);
+ pi.dispatch (info_type::call_load, this->db_, pobj, &d);
};
rsts.load_delayed ();
l.unlock ();
ce = callback_event::post_load;
- pi.dispatch (info_type::call_callback, db, pobj, &ce);
+ pi.dispatch (info_type::call_callback, this->db_, pobj, &ce);
ig.release ();
}