diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-09-28 14:42:23 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-09-28 14:42:23 +0200 |
commit | 0bcac7dde58c0538b9d06f866a0ebd3d60d4001d (patch) | |
tree | 5947692b6daf3e079ce903ad5cc4212dcd39a7c4 /common | |
parent | bc199a1762a1ce3ab1e60ec29568c71a35945280 (diff) |
Make sure size() can still be called once we reached the end of result set
Diffstat (limited to 'common')
-rw-r--r-- | common/query/driver.cxx | 45 | ||||
-rw-r--r-- | common/query/test.std | 1 |
2 files changed, 46 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) { diff --git a/common/query/test.std b/common/query/test.std index e4ed7a0..0548968 100644 --- a/common/query/test.std +++ b/common/query/test.std @@ -99,3 +99,4 @@ Jane Doe 29 married test 016 test 017 test 018 +test 019 |