aboutsummaryrefslogtreecommitdiff
path: root/odb/relational/pgsql
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-08-28 11:39:17 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-08-28 14:15:45 +0200
commit475a7c89e1c858ae8fec466670af4628129a42d4 (patch)
tree371d7084250767ae927e685fb7a5da630626280f /odb/relational/pgsql
parent64d0ceffaaf5f57a3d24a5210bf0ad2a8474a618 (diff)
Add wrapper support for containers
Diffstat (limited to 'odb/relational/pgsql')
-rw-r--r--odb/relational/pgsql/common.cxx11
-rw-r--r--odb/relational/pgsql/common.hxx9
-rw-r--r--odb/relational/pgsql/schema.cxx3
-rw-r--r--odb/relational/pgsql/source.cxx11
4 files changed, 18 insertions, 16 deletions
diff --git a/odb/relational/pgsql/common.cxx b/odb/relational/pgsql/common.cxx
index d6ef9c3..e4d97cc 100644
--- a/odb/relational/pgsql/common.cxx
+++ b/odb/relational/pgsql/common.cxx
@@ -35,22 +35,23 @@ namespace relational
semantics::type& t (type_override_ != 0 ? *type_override_ : m.type ());
- if (semantics::class_* comp = comp_value_wrapper (t))
+ if (semantics::class_* c = comp_value_wrapper (t))
{
// If t is a wrapper, pass the wrapped type. Also pass the
// original, wrapper type.
//
- member_info mi (
- m, *comp, (wrapper (t) ? &t : 0), var, fq_type_override_);
+ member_info mi (m, *c, (wrapper (t) ? &t : 0), var, fq_type_override_);
if (pre (mi))
{
traverse_composite (mi);
post (mi);
}
}
- else if (container (t))
+ else if (semantics::type* c = container_wrapper (t))
{
- member_info mi (m, t, 0, var, fq_type_override_);
+ // The same unwrapping logic as for composite values.
+ //
+ member_info mi (m, *c, (wrapper (t) ? &t : 0), var, fq_type_override_);
if (pre (mi))
{
traverse_container (mi);
diff --git a/odb/relational/pgsql/common.hxx b/odb/relational/pgsql/common.hxx
index f41ca8c..a91c40a 100644
--- a/odb/relational/pgsql/common.hxx
+++ b/odb/relational/pgsql/common.hxx
@@ -40,10 +40,13 @@ namespace relational
string
fq_type (bool unwrap = true) const
{
- // At the moment a wrapped type can only be a composite value.
- //
if (wrapper != 0 && unwrap)
- return t.fq_name ();
+ {
+ // Use the hint from the wrapper.
+ //
+ return t.fq_name (
+ wrapper->get<semantics::names*> ("wrapper-hint"));
+ }
// Use the original type from 'm' instead of 't' since the hint
// may be invalid for a different type. Plus, if a type is
diff --git a/odb/relational/pgsql/schema.cxx b/odb/relational/pgsql/schema.cxx
index 5bfbc71..0e66e79 100644
--- a/odb/relational/pgsql/schema.cxx
+++ b/odb/relational/pgsql/schema.cxx
@@ -186,7 +186,7 @@ namespace relational
}
virtual void
- container (semantics::data_member& m)
+ container (semantics::data_member& m, semantics::type& t)
{
using semantics::type;
using semantics::data_member;
@@ -201,7 +201,6 @@ namespace relational
if (tables_.count (name))
return;
- type& t (m.type ());
type& vt (container_vt (t));
// object_id
diff --git a/odb/relational/pgsql/source.cxx b/odb/relational/pgsql/source.cxx
index 1bba68a..331463d 100644
--- a/odb/relational/pgsql/source.cxx
+++ b/odb/relational/pgsql/source.cxx
@@ -1003,7 +1003,7 @@ namespace relational
container_traits (base const& x): base (x) {}
virtual void
- container_extra (semantics::data_member& m)
+ container_extra (semantics::data_member& m, semantics::type& t)
{
if (!c_.count ("object") || abstract (c_))
return;
@@ -1039,8 +1039,7 @@ namespace relational
semantics::data_member* inv_m (inverse (m, "value"));
bool inv (inv_m != 0);
- semantics::type& mt (m.type ());
- semantics::type& vt (container_vt (mt));
+ semantics::type& vt (container_vt (t));
string id_oid (oids[column_sql_type (m, "id").type]);
@@ -1055,7 +1054,7 @@ namespace relational
{
// many(i)-to-many
//
- if (context::container (inv_m->type ()))
+ if (container_wrapper (inv_m->type ()))
os << oids[column_sql_type (*inv_m, "value").type];
// many(i)-to-one
@@ -1080,7 +1079,7 @@ namespace relational
{
os << id_oid << ",";
- switch (container_kind (mt))
+ switch (container_kind (t))
{
case ck_ordered:
{
@@ -1093,7 +1092,7 @@ namespace relational
case ck_multimap:
{
if (semantics::class_* ktc =
- comp_value_wrapper (container_kt (mt)))
+ comp_value_wrapper (container_kt (t)))
{
instance<statement_oids> st;
st->traverse_composite (m, *ktc, "key", "key");