aboutsummaryrefslogtreecommitdiff
path: root/common/query
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-03-07 10:21:09 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-03-07 10:21:09 +0200
commit382d0972301fb575f36eb2e5d442d735d7da3da4 (patch)
treef6fe9c80389c85e72bf849e8527f09e207cece0e /common/query
parent58f14a5a500b92f6ed34fe20a896ae9c2d777071 (diff)
Use RAII to free select statement results
Diffstat (limited to 'common/query')
-rw-r--r--common/query/driver.cxx19
-rw-r--r--common/query/test.std1
2 files changed, 20 insertions, 0 deletions
diff --git a/common/query/driver.cxx b/common/query/driver.cxx
index 6afd82d..c207955 100644
--- a/common/query/driver.cxx
+++ b/common/query/driver.cxx
@@ -513,6 +513,25 @@ main (int argc, char* argv[])
t.commit ();
}
+
+ // Test empty result set.
+ //
+ cout << "test 018" << endl;
+ {
+ {
+ transaction t (db->begin ());
+ result r (db->query<person> (query::last_name == "None"));
+ assert (r.empty ());
+ t.commit ();
+ }
+
+ {
+ transaction t (db->begin ());
+ result r (db->query<person> (query::last_name == "None"));
+ assert (r.begin () == r.end ());
+ t.commit ();
+ }
+ }
}
catch (const odb::exception& e)
{
diff --git a/common/query/test.std b/common/query/test.std
index 58a2aa0..e4ed7a0 100644
--- a/common/query/test.std
+++ b/common/query/test.std
@@ -98,3 +98,4 @@ Jane Doe 29 married
test 016
test 017
+test 018