summaryrefslogtreecommitdiff
path: root/odb/relational/pgsql
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/relational/pgsql
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/relational/pgsql')
-rw-r--r--odb/relational/pgsql/header.cxx2
-rw-r--r--odb/relational/pgsql/source.cxx10
2 files changed, 6 insertions, 6 deletions
diff --git a/odb/relational/pgsql/header.cxx b/odb/relational/pgsql/header.cxx
index 19fa573..b3566d8 100644
--- a/odb/relational/pgsql/header.cxx
+++ b/odb/relational/pgsql/header.cxx
@@ -31,7 +31,7 @@ namespace relational
if (abst && !poly)
return;
- semantics::data_member* id (id_member (c));
+ data_member_path* id (id_member (c));
semantics::data_member* optimistic (context::optimistic (c));
column_count_type const& cc (column_count (c));
diff --git a/odb/relational/pgsql/source.cxx b/odb/relational/pgsql/source.cxx
index 2bbe232..b8270ac 100644
--- a/odb/relational/pgsql/source.cxx
+++ b/odb/relational/pgsql/source.cxx
@@ -583,16 +583,16 @@ namespace relational
if (p == persist_after_values)
{
- semantics::data_member* id (id_member (c));
+ data_member_path* id (id_member (c));
type* poly_root (polymorphic (c));
bool poly_derived (poly_root != 0 && poly_root != &c);
// Top-level auto id.
//
- if (id != 0 && !poly_derived && id->count ("auto"))
+ if (id != 0 && !poly_derived && auto_ (*id))
r = "RETURNING " +
- convert_from (column_qname (*id, column_prefix ()), *id);
+ convert_from (column_qname (*id), *id->back ());
}
return r;
@@ -610,7 +610,7 @@ namespace relational
if (abst && !poly)
return;
- semantics::data_member* id (id_member (c));
+ data_member_path* id (id_member (c));
semantics::data_member* optimistic (context::optimistic (c));
column_count_type const& cc (column_count (c));
@@ -706,7 +706,7 @@ namespace relational
statement_oids st (statement_insert);
st.traverse (c);
- // Empty array are not portable. So add a dummy member if we
+ // Empty array is not portable. So add a dummy member if we
// are not sending anything with the insert statement.
//
if (cc.total == cc.inverse + cc.optimistic_managed +