aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-11-22 12:09:48 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-11-22 12:09:48 +0200
commitf3e419f52b42cfefa9b3eedbde3697c8b95c92a7 (patch)
tree3213e089f2e58e5c397a8d1282f10aa4dac3f8d8
parent62e4aebe87e7dc19d66ed01fba2ea97bcc5846ad (diff)
Make query result aware of session and const objects
-rw-r--r--odb/mysql/forward.hxx2
-rw-r--r--odb/mysql/result.hxx19
-rw-r--r--odb/mysql/result.txx29
3 files changed, 33 insertions, 17 deletions
diff --git a/odb/mysql/forward.hxx b/odb/mysql/forward.hxx
index 3b36780..d334cb3 100644
--- a/odb/mysql/forward.hxx
+++ b/odb/mysql/forward.hxx
@@ -20,6 +20,8 @@ namespace odb
// Implementation details.
//
+ class select_statement;
+
template <typename T>
class object_statements;
diff --git a/odb/mysql/result.hxx b/odb/mysql/result.hxx
index fe4fcfb..336d46c 100644
--- a/odb/mysql/result.hxx
+++ b/odb/mysql/result.hxx
@@ -24,18 +24,25 @@ namespace odb
class result_impl: public odb::result_impl<T>
{
public:
- typedef object_traits<T> traits;
- typedef typename traits::pointer_type pointer_type;
- typedef typename traits::pointer_traits pointer_traits;
+ typedef typename odb::result_impl<T>::pointer_type pointer_type;
+ typedef typename odb::result_impl<T>::pointer_traits pointer_traits;
+
+ typedef typename odb::result_impl<T>::object_type object_type;
+ typedef typename odb::result_impl<T>::id_type id_type;
+ typedef typename odb::result_impl<T>::object_traits object_traits;
+
virtual
~result_impl ();
result_impl (details::shared_ptr<select_statement> statement,
- object_statements<T>& statements);
+ object_statements<object_type>& statements);
virtual void
- current (T&);
+ current (object_type&);
+
+ virtual id_type
+ current_id ();
virtual void
next ();
@@ -50,7 +57,7 @@ namespace odb
private:
details::shared_ptr<select_statement> statement_;
- object_statements<T>& statements_;
+ object_statements<object_type>& statements_;
};
}
}
diff --git a/odb/mysql/result.txx b/odb/mysql/result.txx
index c342b17..bb1fe01 100644
--- a/odb/mysql/result.txx
+++ b/odb/mysql/result.txx
@@ -16,19 +16,26 @@ namespace odb
template <typename T>
result_impl<T>::
result_impl (details::shared_ptr<select_statement> statement,
- object_statements<T>& statements)
- : statement_ (statement), statements_ (statements)
+ object_statements<object_type>& statements)
+ : odb::result_impl<T> (statements.connection ().database ()),
+ statement_ (statement),
+ statements_ (statements)
{
next ();
}
template <typename T>
void result_impl<T>::
- current (T& x)
+ current (object_type& x)
{
- if (!this->end_)
- traits::init (
- x, statements_.image (), statements_.connection ().database ());
+ object_traits::init (x, statements_.image (), this->database ());
+ }
+
+ template <typename T>
+ typename result_impl<T>::id_type result_impl<T>::
+ current_id ()
+ {
+ return object_traits::id (statements_.image ());
}
template <typename T>
@@ -42,12 +49,12 @@ namespace odb
//
if (statement_->cached ())
{
- typename traits::image_type& im (statements_.image ());
+ typename object_traits::image_type& im (statements_.image ());
if (im.version != statements_.out_image_version ())
{
binding& b (statements_.out_image_binding ());
- traits::bind (b.bind, im, true);
+ object_traits::bind (b.bind, im, true);
statements_.out_image_version (im.version);
b.version++;
}
@@ -59,13 +66,13 @@ namespace odb
{
case select_statement::truncated:
{
- typename traits::image_type& im (statements_.image ());
- traits::grow (im, statements_.out_image_error ());
+ typename object_traits::image_type& im (statements_.image ());
+ object_traits::grow (im, statements_.out_image_error ());
if (im.version != statements_.out_image_version ())
{
binding& b (statements_.out_image_binding ());
- traits::bind (b.bind, im, true);
+ object_traits::bind (b.bind, im, true);
statements_.out_image_version (im.version);
b.version++;
statement_->refetch ();