aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odb/pgsql/no-id-object-result.hxx2
-rw-r--r--odb/pgsql/polymorphic-object-result.hxx2
-rw-r--r--odb/pgsql/polymorphic-object-result.txx4
-rw-r--r--odb/pgsql/polymorphic-object-statements.txx2
-rw-r--r--odb/pgsql/simple-object-result.hxx2
-rw-r--r--odb/pgsql/simple-object-statements.txx2
-rw-r--r--odb/pgsql/traits-calls.hxx81
-rw-r--r--odb/pgsql/view-result.hxx5
-rw-r--r--odb/pgsql/view-result.txx12
9 files changed, 94 insertions, 18 deletions
diff --git a/odb/pgsql/no-id-object-result.hxx b/odb/pgsql/no-id-object-result.hxx
index 83f3ce9..1fbdf75 100644
--- a/odb/pgsql/no-id-object-result.hxx
+++ b/odb/pgsql/no-id-object-result.hxx
@@ -64,7 +64,7 @@ namespace odb
private:
details::shared_ptr<select_statement> statement_;
statements_type& statements_;
- traits_calls<object_type> tc_;
+ object_traits_calls<object_type> tc_;
std::size_t count_;
};
}
diff --git a/odb/pgsql/polymorphic-object-result.hxx b/odb/pgsql/polymorphic-object-result.hxx
index acbfd43..db40e2e 100644
--- a/odb/pgsql/polymorphic-object-result.hxx
+++ b/odb/pgsql/polymorphic-object-result.hxx
@@ -81,7 +81,7 @@ namespace odb
private:
details::shared_ptr<select_statement> statement_;
statements_type& statements_;
- traits_calls<object_type> tc_;
+ object_traits_calls<object_type> tc_;
std::size_t count_;
};
}
diff --git a/odb/pgsql/polymorphic-object-result.txx b/odb/pgsql/polymorphic-object-result.txx
index d2504eb..c92a278 100644
--- a/odb/pgsql/polymorphic-object-result.txx
+++ b/odb/pgsql/polymorphic-object-result.txx
@@ -209,7 +209,7 @@ namespace odb
if (traits::check_version (sts.select_image_versions (), im))
{
binding& b (sts.select_image_binding (traits::depth));
- traits_calls<T> tc (svm);
+ 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 ());
@@ -236,7 +236,7 @@ namespace odb
if (im.version != sts.select_image_version ())
{
binding& b (sts.select_image_binding ());
- traits_calls<R> tc (svm);
+ object_traits_calls<R> tc (svm);
tc.bind (b.bind, im, statement_select);
sts.select_image_version (im.version);
b.version++;
diff --git a/odb/pgsql/polymorphic-object-statements.txx b/odb/pgsql/polymorphic-object-statements.txx
index 694c3e9..f6b223b 100644
--- a/odb/pgsql/polymorphic-object-statements.txx
+++ b/odb/pgsql/polymorphic-object-statements.txx
@@ -138,7 +138,7 @@ namespace odb
// The same code as in object_statements::load_delayed_().
//
- traits_calls<T> tc (svm);
+ object_traits_calls<T> tc (svm);
if (!tc.find_ (sts, &id))
throw object_not_persistent ();
diff --git a/odb/pgsql/simple-object-result.hxx b/odb/pgsql/simple-object-result.hxx
index e6a558b..add9db9 100644
--- a/odb/pgsql/simple-object-result.hxx
+++ b/odb/pgsql/simple-object-result.hxx
@@ -73,7 +73,7 @@ namespace odb
private:
details::shared_ptr<select_statement> statement_;
statements_type& statements_;
- traits_calls<object_type> tc_;
+ object_traits_calls<object_type> tc_;
std::size_t count_;
};
}
diff --git a/odb/pgsql/simple-object-statements.txx b/odb/pgsql/simple-object-statements.txx
index ae96008..9eb671b 100644
--- a/odb/pgsql/simple-object-statements.txx
+++ b/odb/pgsql/simple-object-statements.txx
@@ -114,7 +114,7 @@ namespace odb
if (l.loader == 0)
{
- traits_calls<T> tc (svm);
+ object_traits_calls<T> tc (svm);
if (!tc.find_ (static_cast<STS&> (*this), &l.id))
throw object_not_persistent ();
diff --git a/odb/pgsql/traits-calls.hxx b/odb/pgsql/traits-calls.hxx
index ee91e62..5313596 100644
--- a/odb/pgsql/traits-calls.hxx
+++ b/odb/pgsql/traits-calls.hxx
@@ -20,18 +20,22 @@ namespace odb
{
namespace pgsql
{
+ //
+ // object_traits_calls
+ //
+
template <typename T,
bool versioned = object_traits_impl<T, id_pgsql>::versioned>
- struct traits_calls;
+ struct object_traits_calls;
template <typename T>
- struct traits_calls<T, false>
+ struct object_traits_calls<T, false>
{
typedef object_traits_impl<T, id_pgsql> traits;
typedef typename traits::image_type image_type;
typedef pgsql::bind bind_type;
- traits_calls (const schema_version_migration*) {}
+ object_traits_calls (const schema_version_migration*) {}
const schema_version_migration*
version () const {return 0;}
@@ -80,13 +84,13 @@ namespace odb
};
template <typename T>
- struct traits_calls<T, true>
+ struct object_traits_calls<T, true>
{
typedef object_traits_impl<T, id_pgsql> traits;
typedef typename traits::image_type image_type;
typedef pgsql::bind bind_type;
- traits_calls (const schema_version_migration* svm): svm_ (*svm) {}
+ object_traits_calls (const schema_version_migration* svm): svm_ (*svm) {}
const schema_version_migration*
version () const {return &svm_;}
@@ -136,6 +140,73 @@ namespace odb
private:
const schema_version_migration& svm_;
};
+
+ //
+ // view_traits_calls
+ //
+
+ template <typename T,
+ bool versioned = view_traits_impl<T, id_pgsql>::versioned>
+ struct view_traits_calls;
+
+ template <typename T>
+ struct view_traits_calls<T, false>
+ {
+ typedef view_traits_impl<T, id_pgsql> traits;
+ typedef typename traits::image_type image_type;
+ typedef pgsql::bind bind_type;
+
+ view_traits_calls (const schema_version_migration*) {}
+
+ static bool
+ grow (image_type& i, bool* t)
+ {
+ return traits::grow (i, t);
+ }
+
+ static void
+ bind (bind_type* b, image_type& i)
+ {
+ traits::bind (b, i);
+ }
+
+ static void
+ init (T& o, const image_type& i, odb::database* db)
+ {
+ traits::init (o, i, db);
+ }
+ };
+
+ template <typename T>
+ struct view_traits_calls<T, true>
+ {
+ typedef view_traits_impl<T, id_pgsql> traits;
+ typedef typename traits::image_type image_type;
+ typedef pgsql::bind bind_type;
+
+ view_traits_calls (const schema_version_migration* svm): svm_ (*svm) {}
+
+ bool
+ grow (image_type& i, bool* t) const
+ {
+ return traits::grow (i, t, svm_);
+ }
+
+ void
+ bind (bind_type* b, image_type& i) const
+ {
+ traits::bind (b, i, svm_);
+ }
+
+ void
+ init (T& o, const image_type& i, odb::database* db) const
+ {
+ traits::init (o, i, db, svm_);
+ }
+
+ private:
+ const schema_version_migration& svm_;
+ };
}
}
diff --git a/odb/pgsql/view-result.hxx b/odb/pgsql/view-result.hxx
index 086be0e..2ca6195 100644
--- a/odb/pgsql/view-result.hxx
+++ b/odb/pgsql/view-result.hxx
@@ -9,6 +9,7 @@
#include <cstddef> // std::size_t
+#include <odb/schema-version.hxx>
#include <odb/view-result.hxx>
#include <odb/details/shared-ptr.hxx>
@@ -40,7 +41,8 @@ namespace odb
view_result_impl (const query_base&,
details::shared_ptr<select_statement>,
- statements_type&);
+ statements_type&,
+ const schema_version_migration*);
virtual void
load (view_type&);
@@ -62,6 +64,7 @@ namespace odb
private:
details::shared_ptr<select_statement> statement_;
statements_type& statements_;
+ view_traits_calls<view_type> tc_;
std::size_t count_;
};
}
diff --git a/odb/pgsql/view-result.txx b/odb/pgsql/view-result.txx
index cf29d00..9f126b9 100644
--- a/odb/pgsql/view-result.txx
+++ b/odb/pgsql/view-result.txx
@@ -35,10 +35,12 @@ namespace odb
view_result_impl<T>::
view_result_impl (const query_base&,
details::shared_ptr<select_statement> statement,
- statements_type& statements)
+ statements_type& statements,
+ const schema_version_migration* svm)
: base_type (statements.connection ()),
statement_ (statement),
statements_ (statements),
+ tc_ (svm),
count_ (0)
{
}
@@ -55,7 +57,7 @@ namespace odb
if (im.version != statements_.image_version ())
{
binding& b (statements_.image_binding ());
- view_traits::bind (b.bind, im);
+ tc_.bind (b.bind, im);
statements_.image_version (im.version);
b.version++;
}
@@ -64,13 +66,13 @@ namespace odb
if (r == select_statement::truncated)
{
- if (view_traits::grow (im, statements_.image_truncated ()))
+ if (tc_.grow (im, statements_.image_truncated ()))
im.version++;
if (im.version != statements_.image_version ())
{
binding& b (statements_.image_binding ());
- view_traits::bind (b.bind, im);
+ tc_.bind (b.bind, im);
statements_.image_version (im.version);
b.version++;
statement_->reload ();
@@ -78,7 +80,7 @@ namespace odb
}
view_traits::callback (this->db_, view, callback_event::pre_load);
- view_traits::init (view, im, &this->db_);
+ tc_.init (view, im, &this->db_);
view_traits::callback (this->db_, view, callback_event::post_load);
}