From 55a308d14dc12594c365767d738f71893248f159 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 5 Feb 2015 14:17:07 +0200 Subject: Implement result modifiers in view query condition --- common/view/basics/driver.cxx | 29 +++++++++++++++++++++++++++++ common/view/basics/test.hxx | 18 ++++++++++++++++++ 2 files changed, 47 insertions(+) (limited to 'common') diff --git a/common/view/basics/driver.cxx b/common/view/basics/driver.cxx index e1a72f7..01ae0ab 100644 --- a/common/view/basics/driver.cxx +++ b/common/view/basics/driver.cxx @@ -653,6 +653,35 @@ main (int argc, char* argv[]) t.commit (); } } + + // view13 + // + { + typedef odb::query query; + typedef odb::result result; + + { + transaction t (db->begin ()); + + { + result r (db->query ( + (query::person::age < 32) + + "ORDER BY" + query::employer::name)); + + assert (size (r) == 2); + } + + t.commit (); + } + } + + // view14 + // + { + transaction t (db->begin ()); + assert (size (db->query ()) == 2); + t.commit (); + } } catch (const odb::exception& e) { diff --git a/common/view/basics/test.hxx b/common/view/basics/test.hxx index 18fae4b..e9d61a5 100644 --- a/common/view/basics/test.hxx +++ b/common/view/basics/test.hxx @@ -492,4 +492,22 @@ struct view12 std::string residence; }; +// +// Test 'distinct' result modifier. +// +#pragma db view object(employer) object(person) query(distinct) +struct view13 +{ + std::string name; +}; + +// +// Test 'for_update' result modifier. +// +#pragma db view object(employer) query((?), for_update) +struct view14 +{ + std::string name; +}; + #endif // TEST_HXX -- cgit v1.1