summaryrefslogtreecommitdiff
path: root/odb/processor.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-07-03 18:23:51 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-07-03 18:23:51 +0200
commit80b868be1e7c249daa714b0c7a5f87694edb8664 (patch)
treed8e0dd6eca09d33d70224f7289ae096a0976cd6b /odb/processor.cxx
parent89ba09f073b103953c53e63bd78f644973d9154e (diff)
Implement nested id support
Now the 'id' specifier can optionally include the data member path to the id inside the composite value. For example: #pragma db id(first) std::pair<int, int> p; Note that one somewhat counter-intuitive aspect of this new feature is that the whole member marked with id ('p' in the above example) and not just the actual id member ('p.first' in the above example) is treated as readonly. Such nested id also cannot be automatically assigned (auto specifier).
Diffstat (limited to 'odb/processor.cxx')
-rw-r--r--odb/processor.cxx16
1 files changed, 12 insertions, 4 deletions
diff --git a/odb/processor.cxx b/odb/processor.cxx
index f7a2be2..5dc49f9 100644
--- a/odb/processor.cxx
+++ b/odb/processor.cxx
@@ -46,7 +46,7 @@ namespace
id_tree_type (semantics::names*& hint)
{
context& c (context::current ());
- semantics::data_member& id (*context::id_member (*c.top_object));
+ data_member_path& id (*context::id_member (*c.top_object));
return &c.utype (id, hint);
}
@@ -2109,7 +2109,10 @@ namespace
virtual void
traverse_object_pre (type& c)
{
- semantics::class_* poly_root (polymorphic (c));
+ using semantics::class_;
+ using semantics::data_member;
+
+ class_* poly_root (polymorphic (c));
// Sections.
//
@@ -2199,7 +2202,8 @@ namespace
using namespace semantics;
using semantics::data_member;
- data_member* idm (id_member (*poly_root));
+ data_member_path& id (*id_member (*poly_root));
+ data_member* idm (id.front ());
if (poly_root != &c)
{
@@ -2248,8 +2252,12 @@ namespace
// Mark it as a special kind of id.
//
- m.set ("id", true);
+ m.set ("id", string ());
m.set ("polymorphic-ref", true);
+
+ // Make sure we also use the same column name as the root.
+ //
+ m.set ("column", table_column (column_name (id)));
}
else
{