diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-09-27 11:20:31 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-09-27 11:20:31 +0200 |
commit | a7bd7367e246ec5b6bb2e2f018a05173ff7e6301 (patch) | |
tree | 41e796b972320267f35fce07b9c77fd82029b3e8 /odb/relational/header.hxx | |
parent | 8efcb4e093ec9faab36d49474fd3596a2ce90b13 (diff) |
Add support for associating tables with views
Diffstat (limited to 'odb/relational/header.hxx')
-rw-r--r-- | odb/relational/header.hxx | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/odb/relational/header.hxx b/odb/relational/header.hxx index 50a40b2..1380c49 100644 --- a/odb/relational/header.hxx +++ b/odb/relational/header.hxx @@ -1258,11 +1258,13 @@ namespace relational // query_type // - if (c.count ("objects")) + size_t obj_count (c.get<size_t> ("object-count")); + + if (obj_count != 0) { view_objects& objs (c.get<view_objects> ("objects")); - if (objs.size () > 1) + if (obj_count > 1) { os << "struct query_columns" << "{"; @@ -1271,8 +1273,11 @@ namespace relational i < objs.end (); ++i) { + if (i->kind != view_object::object) + continue; // Skip tables. + bool alias (!i->alias.empty ()); - semantics::class_& o (*i->object); + semantics::class_& o (*i->obj); string const& name (alias ? i->alias : o.name ()); string const& type (o.fq_name ()); @@ -1306,13 +1311,20 @@ namespace relational // For a single object view we generate a shortcut without // an intermediate typedef. // - view_object const& vo (objs[0]); + view_object const* vo (0); + for (view_objects::const_iterator i (objs.begin ()); + vo == 0 && i < objs.end (); + ++i) + { + if (i->kind == view_object::object) + vo = &*i; + } - bool alias (!vo.alias.empty ()); - semantics::class_& o (*vo.object); + bool alias (!vo->alias.empty ()); + semantics::class_& o (*vo->obj); string const& type (o.fq_name ()); - if (alias && vo.alias != table_name (o)) + if (alias && vo->alias != table_name (o)) os << "static const char query_alias[];" << endl << "struct query_type:" << endl |