aboutsummaryrefslogtreecommitdiff
path: root/common/inverse
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-11-25 11:19:03 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-11-25 11:19:03 +0200
commitcd852a8be3a75b0be5bba9a7b6b454849231cd27 (patch)
treeea0e4ab1dff3ab0c369d49be35e7a14f82cc95ff /common/inverse
parent9e26a8a565aa4debe8b7eb86aa74ae39af9e7116 (diff)
Add support for object pointers in query
Diffstat (limited to 'common/inverse')
-rw-r--r--common/inverse/driver.cxx41
1 files changed, 41 insertions, 0 deletions
diff --git a/common/inverse/driver.cxx b/common/inverse/driver.cxx
index e572be2..139c2b6 100644
--- a/common/inverse/driver.cxx
+++ b/common/inverse/driver.cxx
@@ -161,6 +161,47 @@ main (int argc, char* argv[])
delete *x4_2->o1.begin ();
}
+ // query
+ //
+ {
+ // one(i)-to-one
+ //
+ typedef odb::query<obj2> query;
+ typedef odb::result<obj2> result;
+
+ session s;
+ transaction t (db->begin ());
+
+ result r (db->query<obj2> (query::o1::id == "obj1 1"));
+ assert (r.size () == 1);
+ assert (r.begin ()->id == o2->id);
+ assert (r.begin ()->o1->id == o1_1->id);
+
+ t.commit ();
+ }
+
+ {
+ // one(i)-to-many
+ //
+ typedef odb::query<obj3> query;
+ typedef odb::result<obj3> result;
+
+ session s;
+ transaction t (db->begin ());
+
+ result r (db->query<obj3> (query::o1::id == "obj1 1"));
+
+ assert (r.size () == 2);
+
+ for (result::iterator i (r.begin ()); i != r.end (); ++i)
+ {
+ assert (i->id == o3_1->id || i->id == o3_2->id);
+ assert (i->o1->id == o1_1->id);
+ }
+
+ t.commit ();
+ }
+
delete o1_1;
delete o1_2;
}