diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-09-10 14:10:45 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-09-17 12:04:01 +0200 |
commit | 31fd2870497686667f20b2d43467a07482f8ab40 (patch) | |
tree | 9e8fc08cd23b52699c62149f665f32df8892c7c1 /odb/sqlite/polymorphic-object-result.txx | |
parent | c3248cd60418cee935508f62a3436970f9d234b2 (diff) |
Schema versioning support
Diffstat (limited to 'odb/sqlite/polymorphic-object-result.txx')
-rw-r--r-- | odb/sqlite/polymorphic-object-result.txx | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/odb/sqlite/polymorphic-object-result.txx b/odb/sqlite/polymorphic-object-result.txx index 9c79414..6d761b5 100644 --- a/odb/sqlite/polymorphic-object-result.txx +++ b/odb/sqlite/polymorphic-object-result.txx @@ -40,11 +40,13 @@ namespace odb polymorphic_object_result_impl ( const query_base& q, const details::shared_ptr<select_statement>& s, - statements_type& sts) + statements_type& sts, + const schema_version_migration* svm) : base_type (sts.connection ()), params_ (q.parameters ()), statement_ (s), - statements_ (sts) + statements_ (sts), + tc_ (svm) { } @@ -123,7 +125,7 @@ namespace odb callback_event ce (callback_event::pre_load); pi.dispatch (info_type::call_callback, this->db_, pobj, &ce); - object_traits::init (*pobj, i, &this->db_); + tc_.init (*pobj, i, &this->db_); // Initialize the id image and binding and load the rest of the object // (containers, dynamic part, etc). @@ -139,7 +141,7 @@ namespace odb idb.version++; } - object_traits::load_ (statements_, *pobj); + tc_.load_ (statements_, *pobj, false); // Load the dynamic part of the object unless static and dynamic // types are the same. @@ -150,7 +152,7 @@ namespace odb pi.dispatch (info_type::call_load, this->db_, pobj, &d); }; - rsts.load_delayed (); + rsts.load_delayed (tc_.version ()); l.unlock (); ce = callback_event::post_load; @@ -199,14 +201,16 @@ namespace odb typedef object_traits_impl<T, id_sqlite> traits; static bool - rebind (typename traits::statements_type& sts) + rebind (typename traits::statements_type& sts, + const schema_version_migration* svm) { typename traits::image_type& im (sts.image ()); if (traits::check_version (sts.select_image_versions (), im)) { binding& b (sts.select_image_binding (traits::depth)); - traits::bind (b.bind, 0, 0, im, statement_select); + object_traits_calls<T> tc (svm); + tc.bind (b.bind, 0, 0, im, statement_select); traits::update_version ( sts.select_image_versions (), im, sts.select_image_bindings ()); return true; @@ -224,14 +228,16 @@ namespace odb typedef object_traits_impl<R, id_sqlite> traits; static bool - rebind (typename traits::statements_type& sts) + rebind (typename traits::statements_type& sts, + const schema_version_migration* svm) { typename traits::image_type& im (sts.image ()); if (im.version != sts.select_image_version ()) { binding& b (sts.select_image_binding ()); - traits::bind (b.bind, im, statement_select); + object_traits_calls<R> tc (svm); + tc.bind (b.bind, im, statement_select); sts.select_image_version (im.version); b.version++; return true; @@ -250,7 +256,7 @@ namespace odb // The image can grow between calls to load() as a result of other // statements execution. // - image_rebind::rebind (statements_); + image_rebind::rebind (statements_, tc_.version ()); select_statement::result r (statement_->load ()); @@ -258,10 +264,10 @@ namespace odb { typename object_traits::image_type& im (statements_.image ()); - if (object_traits::grow (im, statements_.select_image_truncated ())) + if (tc_.grow (im, statements_.select_image_truncated ())) im.version++; - if (image_rebind::rebind (statements_)) + if (image_rebind::rebind (statements_, tc_.version ())) statement_->reload (); } } |