diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-06-21 10:39:59 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-06-21 10:39:59 +0200 |
commit | 6cd8b9f561b912f264ba4f723845935c40a3cb95 (patch) | |
tree | 5983e0af3d2ee621242ca6707a58c89b9914d8f0 /common/view/driver.cxx | |
parent | 236cd9bb1dd022e64d690c9b0080d1a15c5f61c7 (diff) |
Add support for running tests in dynamic multi-database mode
Only possible in the development build system at this stage.
Diffstat (limited to 'common/view/driver.cxx')
-rw-r--r-- | common/view/driver.cxx | 84 |
1 files changed, 45 insertions, 39 deletions
diff --git a/common/view/driver.cxx b/common/view/driver.cxx index b8a8f3e..2c5c65c 100644 --- a/common/view/driver.cxx +++ b/common/view/driver.cxx @@ -58,11 +58,11 @@ view2_test (const auto_ptr<database>& db) } { -#ifndef DATABASE_ORACLE - result r (db->query<V> ("age < 31")); -#else - result r (db->query<V> ("\"age\" < 31")); -#endif + result r; + if (db->id () != odb::id_oracle) + r = db->query<V> ("age < 31"); + else + r = db->query<V> ("\"age\" < 31"); iterator i (r.begin ()); assert (i != r.end ()); @@ -90,11 +90,11 @@ view4_test (const auto_ptr<database>& db) transaction t (db->begin ()); { -#ifndef DATABASE_ORACLE - result r (db->query<V> ((query::person::age > 30) + "ORDER BY age")); -#else - result r (db->query<V> ((query::person::age > 30) + "ORDER BY \"age\"")); -#endif + result r; + if (db->id () != odb::id_oracle) + r = db->query<V> ((query::person::age > 30) + "ORDER BY age"); + else + r = db->query<V> ((query::person::age > 30) + "ORDER BY \"age\""); iterator i (r.begin ()); @@ -237,20 +237,22 @@ main (int argc, char* argv[]) } { -#ifndef DATABASE_ORACLE - result r (db->query<view1> ("ORDER BY age")); -#else - result r (db->query<view1> ("ORDER BY \"age\"")); -#endif + result r; + if (db->id () != odb::id_oracle) + r = db->query<view1> ("ORDER BY age"); + else + r = db->query<view1> ("ORDER BY \"age\""); + assert (size (r) == 4); } { -#ifndef DATABASE_ORACLE - result r (db->query<view1> ("age < 31 ORDER BY age")); -#else - result r (db->query<view1> ("\"age\" < 31 ORDER BY \"age\"")); -#endif + result r; + if (db->id () != odb::id_oracle) + r = db->query<view1> ("age < 31 ORDER BY age"); + else + r = db->query<view1> ("\"age\" < 31 ORDER BY \"age\""); + view1_check (r); } @@ -289,6 +291,9 @@ main (int argc, char* argv[]) t.commit (); } + // No native parameter support in dynamic multi-database mode. + // +#ifndef DATABASE_COMMON { transaction t (db->begin ()); @@ -306,6 +311,7 @@ main (int argc, char* argv[]) t.commit (); } +#endif } } @@ -317,20 +323,15 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); -#ifndef DATABASE_ORACLE - result r ( - db->query<view1c> ( - "SELECT first, last, age " - "FROM t_view_person " - "WHERE age < 31 ORDER BY age")); -#else - result r ( - db->query<view1c> ( - "SELECT \"first\", \"last\", \"age\" " - "FROM \"t_view_person\" " - "WHERE \"age\" < 31 ORDER BY \"age\"")); -#endif - + result r; + if (db->id () != odb::id_oracle) + r = db->query<view1c> ("SELECT first, last, age " + "FROM t_view_person " + "WHERE age < 31 ORDER BY age"); + else + r = db->query<view1c> ("SELECT \"first\", \"last\", \"age\" " + "FROM \"t_view_person\" " + "WHERE \"age\" < 31 ORDER BY \"age\""); view1_check (r); t.commit (); @@ -346,11 +347,12 @@ main (int argc, char* argv[]) transaction t (db->begin ()); { -#ifndef DATABASE_ORACLE - result r (db->query<view1d> ("age < 31 ORDER BY age")); -#else - result r (db->query<view1d> ("\"age\" < 31 ORDER BY \"age\"")); -#endif + result r; + if (db->id () != odb::id_oracle) + r = db->query<view1d> ("age < 31 ORDER BY age"); + else + r = db->query<view1d> ("\"age\" < 31 ORDER BY \"age\""); + view1_check (r); } @@ -466,12 +468,16 @@ main (int argc, char* argv[]) view6_test<view6b> ( db, odb::query<view6b>::employer::name == "Simple Tech, Inc"); + // No native parameter support in dynamic multi-database mode. + // +#ifndef DATABASE_COMMON view6_test<view6c> ( #ifndef DATABASE_ORACLE db, "e.name = " + odb::query<view6c>::_val ("Simple Tech, Inc")); #else db, "\"e\".\"name\" = " + odb::query<view6c>::_val ("Simple Tech, Inc")); #endif +#endif // view7 // |