aboutsummaryrefslogtreecommitdiff
path: root/common/view
diff options
context:
space:
mode:
authorMichael Shepanski <michael@codesynthesis.com>2014-11-05 14:23:54 +1100
committerBoris Kolpackov <boris@codesynthesis.com>2014-11-10 16:48:59 +0200
commit64b27b86025d160e49bf617143d80671ccb1e0e4 (patch)
tree1abc0df10d797d0d845e0590c1cb9a077e4a42af /common/view
parentdee5f10d1d75eee43596ad1dfb47ecec9e0b1307 (diff)
Implement {query,execute}_{one,value}() shortcut functions
Useful in situations where the query is know to return at most one element (*_one) or exactly one element (*_value).
Diffstat (limited to 'common/view')
-rw-r--r--common/view/driver.cxx19
1 files changed, 19 insertions, 0 deletions
diff --git a/common/view/driver.cxx b/common/view/driver.cxx
index 7ef8272..28c3ba0 100644
--- a/common/view/driver.cxx
+++ b/common/view/driver.cxx
@@ -76,6 +76,25 @@ view2_test (const auto_ptr<database>& db)
assert (i->count == 2);
}
+ {
+ auto_ptr<V> v (db->query_one<V> ());
+ assert (v->count == 4);
+ }
+
+ {
+ auto_ptr<V> v;
+ if (db->id () != odb::id_oracle)
+ v.reset (db->query_one<V> ("age < 31"));
+ else
+ v.reset (db->query_one<V> ("\"age\" < 31"));
+ assert (v->count == 2);
+ }
+
+ {
+ auto_ptr<V> v (db->query_one<V> (query::age < 31));
+ assert (v->count == 2);
+ }
+
t.commit ();
}