diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-10-13 10:09:02 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-10-19 11:41:11 +0200 |
commit | 52c34521dcb4778713b922442222cc0e5e413b71 (patch) | |
tree | 43cf175deee8e2c03016720c9f766400d7f5de82 | |
parent | f2e4c2c70344dd1a98593cfbe9256d1b3ed54f27 (diff) |
Add another case to prepared query test
-rw-r--r-- | common/prepared/driver.cxx | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/common/prepared/driver.cxx b/common/prepared/driver.cxx index 6738e6b..1ea4108 100644 --- a/common/prepared/driver.cxx +++ b/common/prepared/driver.cxx @@ -69,7 +69,7 @@ main (int argc, char* argv[]) typedef odb::prepared_query<person> prep_query; typedef odb::result<person> result; - // Uncached query. + // Uncached query in the same transaction. // { transaction t (db->begin ()); @@ -95,6 +95,38 @@ main (int argc, char* argv[]) t.commit (); } + // Uncached query in multiple transaction. + // + { + connection_ptr c (db->connection ()); + + unsigned short age (90); + prep_query pq ( + c->prepare_query<person> ( + "person-age-query", + query::age > query::_ref (age))); + + for (unsigned short i (1); i < 6; ++i, age -= 10) + { + transaction t (c->begin ()); + + result r (pq.execute ()); + assert (size (r) == i); + + t.commit (); + } + + transaction t (c->begin ()); + + age = 90; + result r (pq.execute ()); + result::iterator i (r.begin ()); + assert (i != r.end () && i->name_ == "John First" && i->age_ == 91); + assert (++i == r.end ()); + + t.commit (); + } + // Cached query without parameters. // { |