aboutsummaryrefslogtreecommitdiff
path: root/common/prepared
diff options
context:
space:
mode:
Diffstat (limited to 'common/prepared')
-rw-r--r--common/prepared/driver.cxx34
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.
//
{