From 5407e260ac888d0428012df757145a6f6dee34ca Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 2 Feb 2015 14:53:05 +0200 Subject: Cache result in query_one(), query_value() --- odb/database.ixx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'odb') 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::pointer_type database:: query_one_ (const Q& q) { - return query_::call (*this, q).one (); + result r (query_::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 inline bool database:: query_one_ (const Q& q, T& o) { - return query_::call (*this, q).one (o); + result r (query_::call (*this, q)); + r.cache (); // See above. + return r.one (o); } template inline T database:: query_value_ (const Q& q) { + result r (query_::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_::call (*this, q).value (o); + r.value (o); return o; } -- cgit v1.1