aboutsummaryrefslogtreecommitdiff
path: root/composite
diff options
context:
space:
mode:
authorMichael Shepanski <michael@codesynthesis.com>2014-11-06 16:33:35 +1100
committerBoris Kolpackov <boris@codesynthesis.com>2014-11-10 16:48:13 +0200
commit51a01cfebf933d270bf7b7fadb0fb3ca3b7a4cd5 (patch)
tree40ca9efb48c65e88822bcb7538d64bf1299d7aaf /composite
parentf7d0e9c620d7c3117074e2618f2bc75699d6f2f0 (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 'composite')
-rw-r--r--composite/driver.cxx10
1 files changed, 5 insertions, 5 deletions
diff --git a/composite/driver.cxx b/composite/driver.cxx
index aaedf17..fc228bf 100644
--- a/composite/driver.cxx
+++ b/composite/driver.cxx
@@ -84,16 +84,16 @@ main (int argc, char* argv[])
//
{
typedef odb::query<person> query;
- typedef odb::result<person> result;
transaction t (db->begin ());
- result r (db->query<person> (
- query::name.extras.nickname == "Squeaky"));
+ auto_ptr<person> p (
+ db->query_one<person> (
+ query::name.extras.nickname == "Squeaky"));
- if (!r.empty ())
+ if (p.get () != 0)
{
- name& n (r.begin ()->name ());
+ name& n (p->name ());
cout << n.title () << " " << n.first () << " " << n.last () << endl;
}