aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-02-02 14:53:05 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-02-02 14:53:05 +0200
commit5407e260ac888d0428012df757145a6f6dee34ca (patch)
treec6d52af124141b25a1419f7ef8d87b7ad13bc1e1
parent19c79b5defb7af20d482aaaaf6ab03804edc951d (diff)
Cache result in query_one(), query_value()
-rw-r--r--odb/database.ixx19
1 files changed, 16 insertions, 3 deletions
diff --git a/odb/database.ixx b/odb/database.ixx
index 43dae6a..230f9db 100644
--- a/odb/database.ixx
+++ b/odb/database.ixx
@@ -826,25 +826,38 @@ namespace odb
inline typename object_traits<T>::pointer_type database::
query_one_ (const Q& q)
{
- return query_<T, DB>::call (*this, q).one ();
+ result<T> r (query_<T, DB>::call (*this, q));
+
+ // We still have to cache the result since loading the object
+ // may result in loading of it's related objects and that would
+ // invalidate the result even for just getting the 'end' status.
+ //
+ r.cache ();
+
+ return r.one ();
}
template <typename T, database_id DB, typename Q>
inline bool database::
query_one_ (const Q& q, T& o)
{
- return query_<T, DB>::call (*this, q).one (o);
+ result<T> r (query_<T, DB>::call (*this, q));
+ r.cache (); // See above.
+ return r.one (o);
}
template <typename T, database_id DB, typename Q>
inline T database::
query_value_ (const Q& q)
{
+ result<T> r (query_<T, DB>::call (*this, q));
+ r.cache (); // See above.
+
// Compiler error pointing here? The object must be default-constructible
// in order to use the return-by-value API.
//
T o;
- query_<T, DB>::call (*this, q).value (o);
+ r.value (o);
return o;
}