summaryrefslogtreecommitdiff
path: root/odb/relational/source.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-03-25 13:06:51 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-03-25 13:06:51 +0200
commit3b53b9157b610805b0d5c436bb01c0fe275390b9 (patch)
treea9e7fb781793214802c963ae2e3247cc5892f9d2 /odb/relational/source.hxx
parent8f59ca1a8d7093655f8f7d61f101abc6df3839d5 (diff)
Further generalization work for SQLite support
Diffstat (limited to 'odb/relational/source.hxx')
-rw-r--r--odb/relational/source.hxx23
1 files changed, 16 insertions, 7 deletions
diff --git a/odb/relational/source.hxx b/odb/relational/source.hxx
index 3bb238a..da66b11 100644
--- a/odb/relational/source.hxx
+++ b/odb/relational/source.hxx
@@ -548,6 +548,15 @@ namespace relational
obj_scope_ = "access::object_traits< " + obj.fq_name () + " >";
}
+ // Unless the database system can execute several interleaving
+ // statements, cache the result set.
+ //
+ virtual void
+ cache_result (string const& statement)
+ {
+ os << statement << ".cache ();";
+ }
+
virtual void
container (semantics::data_member& m)
{
@@ -1396,11 +1405,11 @@ namespace relational
<< "select_statement& st (sts.select_all_statement ());"
<< "st.execute ();";
- // If we are loading eager object pointers, cache the result
- // since we will be loading other objects.
+ // If we are loading eager object pointers, we may need to cache
+ // the result since we will be loading other objects.
//
if (eager_ptr)
- os << "st.cache ();";
+ cache_result ("st");
os << "select_statement::result r (st.fetch ());";
@@ -2275,7 +2284,7 @@ namespace relational
<< endl
<< "details::shared_ptr<odb::result_impl<object_type> > r (" << endl
<< "new (details::shared) " << db <<
- "::result_impl<object_type> (st, sts));"
+ "::result_impl<object_type> (q, st, sts));"
<< "return result<object_type> (r);"
<< "}";
@@ -2299,14 +2308,14 @@ namespace relational
<< endl
<< "details::shared_ptr<odb::result_impl<const object_type> > r (" << endl
<< "new (details::shared) " << db <<
- "::result_impl<const object_type> (st, sts));"
+ "::result_impl<const object_type> (q, st, sts));"
<< "return result<const object_type> (r);"
<< "}";
os << "void " << traits << "::" << endl
<< "query_ (database&," << endl
<< "const query_type& q," << endl
- << db << "::object_statements< object_type >& sts,"
+ << db << "::object_statements< object_type >& sts," << endl
<< "details::shared_ptr<" << db << "::select_statement>& st)"
<< "{"
<< "using namespace " << db << ";"
@@ -2323,7 +2332,7 @@ namespace relational
<< "st.reset (new (details::shared) select_statement (" << endl
<< "sts.connection ()," << endl
<< "query_clause + q.clause ()," << endl
- << "q.parameters ()," << endl
+ << "q.parameters_binding ()," << endl
<< "imb));"
<< "st->execute ();"
<< "}";