From 6465f0b9cf542cfd1fb77687cdad47fde28c9fad Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 2 Oct 2011 19:12:47 +0200 Subject: Handle object pointers when comparing view and object data member types Also issues an error if an object member associated with a view member is transient or inverse. --- common/view/driver.cxx | 23 +++++++++++++++++++++++ common/view/test.hxx | 19 ++++++++++++++----- 2 files changed, 37 insertions(+), 5 deletions(-) (limited to 'common/view') diff --git a/common/view/driver.cxx b/common/view/driver.cxx index a3ef34f..a6048dd 100644 --- a/common/view/driver.cxx +++ b/common/view/driver.cxx @@ -575,6 +575,29 @@ main (int argc, char* argv[]) t.commit (); } } + + // view12 + // + { + typedef odb::query query; + typedef odb::result result; + + { + transaction t (db->begin ()); + + { + result r (db->query (query::last_name == "Dirt")); + + result::iterator i (r.begin ()); + + assert (i != r.end ()); + assert (i->residence == "US"); + assert (++i == r.end ()); + } + + t.commit (); + } + } } catch (const odb::exception& e) { diff --git a/common/view/test.hxx b/common/view/test.hxx index b5b9d65..3812662 100644 --- a/common/view/test.hxx +++ b/common/view/test.hxx @@ -77,10 +77,10 @@ struct person #pragma db id unsigned long id; - #pragma db column ("first") + #pragma db column("first") std::string first_name_; - #pragma db column ("last") + #pragma db column("last") std::string last_name_; unsigned short age; @@ -383,10 +383,10 @@ struct view7 query (wife::husband.is_not_null ()) struct view8 { - #pragma db column (wife::first_name_) + #pragma db column(wife::first_name_) std::string wife_name; - #pragma db column (husb::first_name_) + #pragma db column(husb::first_name_) std::string husb_name; }; @@ -421,8 +421,17 @@ struct view11 { std::string last_name; - #pragma db column (person::measures.hight) + #pragma db column(person::measures.hight) unsigned short hight; }; +// +// Extract object pointer as object id. +// +#pragma db view object(person) +struct view12 +{ + std::string residence; +}; + #endif // TEST_HXX -- cgit v1.1