aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odb/sqlite/container-statements.hxx37
-rw-r--r--odb/sqlite/container-statements.txx6
-rw-r--r--odb/sqlite/forward.hxx1
-rw-r--r--odb/sqlite/result.txx18
4 files changed, 36 insertions, 26 deletions
diff --git a/odb/sqlite/container-statements.hxx b/odb/sqlite/container-statements.hxx
index 9bff64c..e0df250 100644
--- a/odb/sqlite/container-statements.hxx
+++ b/odb/sqlite/container-statements.hxx
@@ -32,7 +32,6 @@ namespace odb
public:
typedef T traits;
- typedef typename traits::id_image_type id_image_type;
typedef typename traits::data_image_type data_image_type;
typedef typename traits::cond_image_type cond_image_type;
@@ -60,18 +59,18 @@ namespace odb
return functions_;
}
- // Id image (external).
+ // Id image binding (external).
//
- id_image_type&
- id_image ()
+ const binding&
+ id_binding ()
{
- return *id_image_;
+ return *id_binding_;
}
void
- id_image (id_image_type& i)
+ id_binding (const binding& b)
{
- id_image_ = &i;
+ id_binding_ = &b;
}
// Condition image.
@@ -82,7 +81,7 @@ namespace odb
return cond_image_;
}
- std::size_t
+ std::size_t
cond_image_version () const
{
return cond_image_version_;
@@ -95,15 +94,15 @@ namespace odb
}
std::size_t
- cond_id_image_version () const
+ cond_id_binding_version () const
{
- return cond_id_image_version_;
+ return cond_id_binding_version_;
}
void
- cond_id_image_version (std::size_t v)
+ cond_id_binding_version (std::size_t v)
{
- cond_id_image_version_ = v;
+ cond_id_binding_version_ = v;
}
binding&
@@ -133,15 +132,15 @@ namespace odb
}
std::size_t
- data_id_image_version () const
+ data_id_binding_version () const
{
- return data_id_image_version_;
+ return data_id_binding_version_;
}
void
- data_id_image_version (std::size_t v)
+ data_id_binding_version (std::size_t v)
{
- data_id_image_version_ = v;
+ data_id_binding_version_ = v;
}
binding&
@@ -216,17 +215,17 @@ namespace odb
connection_type& conn_;
functions_type functions_;
- id_image_type* id_image_;
+ const binding* id_binding_;
cond_image_type cond_image_;
std::size_t cond_image_version_;
- std::size_t cond_id_image_version_;
+ std::size_t cond_id_binding_version_;
binding cond_image_binding_;
bind cond_image_bind_[traits::cond_column_count];
data_image_type data_image_;
std::size_t data_image_version_;
- std::size_t data_id_image_version_;
+ std::size_t data_id_binding_version_;
binding data_image_binding_;
bind data_image_bind_[traits::data_column_count];
bool data_image_truncated_[traits::data_column_count];
diff --git a/odb/sqlite/container-statements.txx b/odb/sqlite/container-statements.txx
index bfef187..15bd4a7 100644
--- a/odb/sqlite/container-statements.txx
+++ b/odb/sqlite/container-statements.txx
@@ -21,17 +21,17 @@ namespace odb
&traits::insert_one,
&traits::load_all,
&traits::delete_all),
- id_image_ (0),
+ id_binding_ (0),
cond_image_binding_ (cond_image_bind_, traits::cond_column_count),
data_image_binding_ (data_image_bind_, traits::data_column_count)
{
cond_image_.version = 0;
cond_image_version_ = 0;
- cond_id_image_version_ = 0;
+ cond_id_binding_version_ = 0;
data_image_.version = 0;
data_image_version_ = 0;
- data_id_image_version_ = 0;
+ data_id_binding_version_ = 0;
std::memset (cond_image_bind_, 0, sizeof (cond_image_bind_));
std::memset (data_image_bind_, 0, sizeof (data_image_bind_));
diff --git a/odb/sqlite/forward.hxx b/odb/sqlite/forward.hxx
index 7688b9c..63c3be4 100644
--- a/odb/sqlite/forward.hxx
+++ b/odb/sqlite/forward.hxx
@@ -22,6 +22,7 @@ namespace odb
// Implementation details.
//
+ class binding;
class select_statement;
template <typename T>
diff --git a/odb/sqlite/result.txx b/odb/sqlite/result.txx
index 83dd4b0..daf4d39 100644
--- a/odb/sqlite/result.txx
+++ b/odb/sqlite/result.txx
@@ -37,13 +37,23 @@ namespace odb
assert (!statements_.locked ());
typename object_statements<object_type>::auto_lock l (statements_);
- typename object_traits::image_type& im (statements_.image ());
- object_traits::init (obj, im, this->database ());
+ typename object_traits::image_type& i (statements_.image ());
+ object_traits::init (obj, i, this->database ());
- // Initialize the id image and load the rest of the object
+ // Initialize the id image and binding and load the rest of the object
// (containers, etc).
//
- object_traits::init (statements_.id_image (), object_traits::id (im));
+ typename object_traits::id_image_type& idi (statements_.id_image ());
+ object_traits::init (idi, object_traits::id (i));
+
+ binding& idb (statements_.id_image_binding ());
+ if (idi.version != statements_.id_image_version () || idb.version == 0)
+ {
+ object_traits::bind (idb.bind, idi);
+ statements_.id_image_version (idi.version);
+ idb.version++;
+ }
+
object_traits::load_ (statements_, obj);
statements_.load_delayed ();