diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-07-03 18:23:51 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-07-03 18:23:51 +0200 |
commit | 80b868be1e7c249daa714b0c7a5f87694edb8664 (patch) | |
tree | d8e0dd6eca09d33d70224f7289ae096a0976cd6b /odb/relational/validator.cxx | |
parent | 89ba09f073b103953c53e63bd78f644973d9154e (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/relational/validator.cxx')
-rw-r--r-- | odb/relational/validator.cxx | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/odb/relational/validator.cxx b/odb/relational/validator.cxx index 5dea25f..f78c145 100644 --- a/odb/relational/validator.cxx +++ b/odb/relational/validator.cxx @@ -325,20 +325,20 @@ namespace relational virtual void traverse_object (type& c) { - semantics::data_member* id (id_member (c)); + data_member_path* id (id_member (c)); if (id != 0) { if (semantics::class_* cm = composite_wrapper (utype (*id))) { + location idl (id->front ()->location ()); + // Composite id cannot be auto. // if (auto_ (*id)) { - os << id->file () << ":" << id->line () << ":" << id->column () - << ": error: composite id cannot be automatically assigned" - << endl; - + error (idl) << "composite id cannot be automatically assigned" + << endl; valid_ = false; } @@ -350,8 +350,7 @@ namespace relational composite_id_members_.traverse (*cm); if (!valid_) - os << id->file () << ":" << id->line () << ":" << id->column () - << ": info: composite id is defined here" << endl; + info (idl) << "composite id is defined here" << endl; } // Check that the composite value type is default-constructible. @@ -366,8 +365,7 @@ namespace relational << ": info: provide default constructor for this value type" << endl; - os << id->file () << ":" << id->line () << ":" << id->column () - << ": info: composite id is defined here" << endl; + info (idl) << "composite id is defined here" << endl; valid_ = false; } |