aboutsummaryrefslogtreecommitdiff
path: root/common/query/driver.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-09-28 14:42:23 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-09-28 14:42:23 +0200
commit0bcac7dde58c0538b9d06f866a0ebd3d60d4001d (patch)
tree5947692b6daf3e079ce903ad5cc4212dcd39a7c4 /common/query/driver.cxx
parentbc199a1762a1ce3ab1e60ec29568c71a35945280 (diff)
Make sure size() can still be called once we reached the end of result set
Diffstat (limited to 'common/query/driver.cxx')
-rw-r--r--common/query/driver.cxx45
1 files changed, 45 insertions, 0 deletions
diff --git a/common/query/driver.cxx b/common/query/driver.cxx
index cc92f41..3c3c753 100644
--- a/common/query/driver.cxx
+++ b/common/query/driver.cxx
@@ -542,6 +542,51 @@ main (int argc, char* argv[])
t.commit ();
}
}
+
+ // Test size() validity at the beginning/middle/end of result set.
+ //
+ cout << "test 019" << endl;
+#if !defined(DATABASE_SQLITE) && \
+ !defined(DATABASE_ORACLE) && \
+ !defined(DATABASE_MSSQL)
+ {
+ {
+ transaction t (db->begin ());
+ result r (db->query<person> ());
+ assert (r.size () == 4);
+ result::iterator i (r.begin ());
+ assert (r.size () == 4);
+ ++i;
+ ++i;
+ ++i;
+ assert (r.size () == 4);
+ ++i;
+ assert (r.size () == 4);
+ }
+
+ {
+ transaction t (db->begin ());
+ result r (db->query<person> (false));
+ result::iterator i (r.begin ());
+ ++i;
+ ++i;
+ r.cache ();
+ assert (r.size () == 4);
+ ++i;
+ assert (r.size () == 4);
+ ++i;
+ assert (r.size () == 4);
+ }
+
+ {
+ transaction t (db->begin ());
+ result r (db->query<person> (query::last_name == "None"));
+ assert (r.size () == 0);
+ for (result::iterator i (r.begin ()); i != r.end (); ++i) ;
+ assert (r.size () == 0);
+ }
+ }
+#endif
}
catch (const odb::exception& e)
{