diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-09-04 12:57:25 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-09-04 12:57:25 +0200 |
commit | 259a683ec2a4f777f605bdd527b9882c3a965ee3 (patch) | |
tree | a8ffb2ed0b71397ba2b4c5176fad1405eff4f153 | |
parent | 3b9fabfc20089fe9e9279a287c1db5bb37a6d275 (diff) |
Container versioning support
-rw-r--r-- | odb/pgsql/container-statements.hxx | 10 | ||||
-rw-r--r-- | odb/pgsql/container-statements.txx | 3 | ||||
-rw-r--r-- | odb/pgsql/polymorphic-object-result.txx | 2 | ||||
-rw-r--r-- | odb/pgsql/polymorphic-object-statements.txx | 2 | ||||
-rw-r--r-- | odb/pgsql/simple-object-result.txx | 2 | ||||
-rw-r--r-- | odb/pgsql/simple-object-statements.txx | 2 | ||||
-rw-r--r-- | odb/pgsql/traits-calls.hxx | 12 |
7 files changed, 28 insertions, 5 deletions
diff --git a/odb/pgsql/container-statements.hxx b/odb/pgsql/container-statements.hxx index d77eec9..3dcecf2 100644 --- a/odb/pgsql/container-statements.hxx +++ b/odb/pgsql/container-statements.hxx @@ -10,6 +10,7 @@ #include <cstddef> // std::size_t #include <odb/forward.hxx> +#include <odb/schema-version.hxx> #include <odb/traits.hxx> #include <odb/pgsql/version.hxx> @@ -61,6 +62,14 @@ namespace odb return functions_; } + // + // + const schema_version_migration& + version_migration () const {return *svm_;} + + void + version_migration (const schema_version_migration& svm) {svm_ = &svm;} + // Id image binding (external). // const binding& @@ -205,6 +214,7 @@ namespace odb const char* delete_text_; bool versioned_; + const schema_version_migration* svm_; details::shared_ptr<insert_statement_type> insert_; details::shared_ptr<select_statement_type> select_; diff --git a/odb/pgsql/container-statements.txx b/odb/pgsql/container-statements.txx index 1af19bb..6b35690 100644 --- a/odb/pgsql/container-statements.txx +++ b/odb/pgsql/container-statements.txx @@ -24,7 +24,8 @@ namespace odb functions_ (this), insert_image_binding_ (0, 0), // Initialized by impl. insert_image_native_binding_ (0, 0, 0, 0), // Initialized by impl. - select_image_binding_ (0, 0) // Initialized by impl. + select_image_binding_ (0, 0), // Initialized by impl. + svm_ (0) { functions_.insert_ = &traits::insert; functions_.select_ = &traits::select; diff --git a/odb/pgsql/polymorphic-object-result.txx b/odb/pgsql/polymorphic-object-result.txx index 233d7ce..d2504eb 100644 --- a/odb/pgsql/polymorphic-object-result.txx +++ b/odb/pgsql/polymorphic-object-result.txx @@ -139,7 +139,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. diff --git a/odb/pgsql/polymorphic-object-statements.txx b/odb/pgsql/polymorphic-object-statements.txx index cc8d31a..694c3e9 100644 --- a/odb/pgsql/polymorphic-object-statements.txx +++ b/odb/pgsql/polymorphic-object-statements.txx @@ -145,7 +145,7 @@ namespace odb object_traits::callback (db, obj, callback_event::pre_load); tc.init (obj, sts.image (), &db); - object_traits::load_ (sts, obj); // Load containers, etc. + tc.load_ (sts, obj, false); // Load containers, etc. rsts.load_delayed (svm); diff --git a/odb/pgsql/simple-object-result.txx b/odb/pgsql/simple-object-result.txx index 02d8e6d..8466303 100644 --- a/odb/pgsql/simple-object-result.txx +++ b/odb/pgsql/simple-object-result.txx @@ -78,7 +78,7 @@ namespace odb idb.version++; } - object_traits::load_ (statements_, obj); + tc_.load_ (statements_, obj, false); statements_.load_delayed (tc_.version ()); l.unlock (); object_traits::callback (this->db_, obj, callback_event::post_load); diff --git a/odb/pgsql/simple-object-statements.txx b/odb/pgsql/simple-object-statements.txx index 5933aa5..ae96008 100644 --- a/odb/pgsql/simple-object-statements.txx +++ b/odb/pgsql/simple-object-statements.txx @@ -129,7 +129,7 @@ namespace odb // Load containers, etc. // - object_traits::load_ (static_cast<STS&> (*this), *l.obj); + tc.load_ (static_cast<STS&> (*this), *l.obj, false); if (!delayed_.empty ()) load_delayed_<STS> (svm); diff --git a/odb/pgsql/traits-calls.hxx b/odb/pgsql/traits-calls.hxx index 5f2e11b..ee91e62 100644 --- a/odb/pgsql/traits-calls.hxx +++ b/odb/pgsql/traits-calls.hxx @@ -71,6 +71,12 @@ namespace odb { return traits::find_ (sts, id); } + + static void + load_ (typename traits::statements_type& sts, T& o, bool reload) + { + return traits::load_ (sts, o, reload); + } }; template <typename T> @@ -121,6 +127,12 @@ namespace odb return traits::find_ (sts, id, svm_); } + void + load_ (typename traits::statements_type& sts, T& o, bool reload) const + { + return traits::load_ (sts, o, reload, svm_); + } + private: const schema_version_migration& svm_; }; |