aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-11-26 15:48:28 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-11-26 15:48:28 +0200
commit3b27ca96f2f4c2b76f65675a988482e19220fa66 (patch)
treee6b91b7d390a92a4995d61464e4ac42d2dff4e5d /common
parent30895144f680a8b9a8b4b6313edb726361d36000 (diff)
Postpone fetching of the data for cached results
This way if an object of the same type is loaded in between iteration, the fetched image won't be messed up.
Diffstat (limited to 'common')
-rw-r--r--common/query/driver.cxx18
-rw-r--r--common/query/test.std1
2 files changed, 19 insertions, 0 deletions
diff --git a/common/query/driver.cxx b/common/query/driver.cxx
index 9ff596b..5a77ae9 100644
--- a/common/query/driver.cxx
+++ b/common/query/driver.cxx
@@ -383,6 +383,24 @@ main (int argc, char* argv[])
print (r);
t.commit ();
}
+
+ // Test that loading of the same object type during iteration does
+ // not invalidate the result.
+ //
+ cout << "test 014" << endl;
+ {
+ transaction t (db->begin ());
+ result r (db->query<person> (query::last_name == "Doe"));
+
+ assert (r.size () == 2);
+
+ result::iterator i (r.begin ());
+ i++;
+ auto_ptr<person> joe (db->load<person> (3));
+ assert (i->last_name_ == "Doe");
+
+ t.commit ();
+ }
}
catch (const odb::exception& e)
{
diff --git a/common/query/test.std b/common/query/test.std
index e065765..14f3205 100644
--- a/common/query/test.std
+++ b/common/query/test.std
@@ -91,3 +91,4 @@ Johansen J Johansen 32 single
test 013
Joe Squeaky Dirt 31 single
+test 014