diff options
Diffstat (limited to 'common/query')
-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 |