aboutsummaryrefslogtreecommitdiff
path: root/common/view/driver.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-09-27 11:20:31 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-09-27 11:20:31 +0200
commit7a1be868574beb4843d189a7d9d758d608da65c9 (patch)
treebbb437e366f9b5068197e1cf4808d5545d781435 /common/view/driver.cxx
parentadbf41f849da186057edfbd1873f49433dc5efd2 (diff)
Add support for associating tables with views
Diffstat (limited to 'common/view/driver.cxx')
-rw-r--r--common/view/driver.cxx38
1 files changed, 31 insertions, 7 deletions
diff --git a/common/view/driver.cxx b/common/view/driver.cxx
index 7d921cd..cd734bd 100644
--- a/common/view/driver.cxx
+++ b/common/view/driver.cxx
@@ -134,7 +134,7 @@ view4_test (const auto_ptr<database>& db)
template <typename V>
void
-view6_test (const auto_ptr<database>& db)
+view6_test (const auto_ptr<database>& db, const odb::query<V>& q)
{
typedef odb::query<V> query;
typedef odb::result<V> result;
@@ -143,9 +143,7 @@ view6_test (const auto_ptr<database>& db)
transaction t (db->begin ());
{
- result r (
- db->query<V> (
- query::employer::name == "Simple Tech, Inc"));
+ result r (db->query<V> (q));
iterator i (r.begin ());
@@ -312,6 +310,24 @@ main (int argc, char* argv[])
}
}
+ // view1d
+ //
+ {
+ typedef odb::query<view1d> query;
+ typedef odb::result<view1d> result;
+
+ {
+ transaction t (db->begin ());
+
+ {
+ result r (db->query<view1d> ("age < 31 ORDER BY age"));
+ view1_check (r);
+ }
+
+ t.commit ();
+ }
+ }
+
// view2
//
view2_test<view2> (db);
@@ -412,9 +428,17 @@ main (int argc, char* argv[])
// view6
//
- view6_test<view6> (db);
- view6_test<view6a> (db);
- view6_test<view6b> (db);
+ view6_test<view6> (
+ db, odb::query<view6>::employer::name == "Simple Tech, Inc");
+
+ view6_test<view6a> (
+ db, odb::query<view6a>::employer::name == "Simple Tech, Inc");
+
+ view6_test<view6b> (
+ db, odb::query<view6b>::employer::name == "Simple Tech, Inc");
+
+ view6_test<view6c> (
+ db, "e.name = " + odb::query<view6c>::_val ("Simple Tech, Inc"));
// view7
//