summaryrefslogtreecommitdiff
path: root/odb/relational/pgsql/source.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-08-26 12:13:18 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-08-28 14:15:45 +0200
commit64d0ceffaaf5f57a3d24a5210bf0ad2a8474a618 (patch)
tree98115a01b0bd2e9ddfdc6ff3a0f7470915de483a /odb/relational/pgsql/source.cxx
parent061a16256eef2c2df53e2e145d16f17270c2de82 (diff)
Add wrapper support for composite values
NULL semantics for composite values is not yet supported.
Diffstat (limited to 'odb/relational/pgsql/source.cxx')
-rw-r--r--odb/relational/pgsql/source.cxx40
1 files changed, 34 insertions, 6 deletions
diff --git a/odb/relational/pgsql/source.cxx b/odb/relational/pgsql/source.cxx
index bfc26ba..1bba68a 100644
--- a/odb/relational/pgsql/source.cxx
+++ b/odb/relational/pgsql/source.cxx
@@ -420,6 +420,18 @@ namespace relational
<< "//" << endl;
}
+ // If this is a wrapped composite value, then we need to
+ // "unwrap" it. For simple values this is taken care of
+ // by the value_traits specializations.
+ //
+ if (mi.wrapper != 0 && comp_value (mi.t))
+ {
+ // Here we need the wrapper type, not the wrapped type.
+ //
+ member = "wrapper_traits< " + mi.fq_type (false) + " >::" +
+ "get_ref (" + member + ")";
+ }
+
if (comp_value (mi.t))
traits = "composite_value_traits< " + mi.fq_type () + " >";
else
@@ -515,8 +527,9 @@ namespace relational
virtual void
traverse_composite (member_info& mi)
{
- os << "if (" << traits << "::init (i." << mi.var << "value, " <<
- member << "))"
+ os << "if (" << traits << "::init (" << endl
+ << "i." << mi.var << "value," << endl
+ << member << "))"
<< "{"
<< "grew = true;"
<< "}";
@@ -650,6 +663,18 @@ namespace relational
<< "//" << endl;
}
+ // If this is a wrapped composite value, then we need to
+ // "unwrap" it. For simple values this is taken care of
+ // by the value_traits specializations.
+ //
+ if (mi.wrapper != 0 && comp_value (mi.t))
+ {
+ // Here we need the wrapper type, not the wrapped type.
+ //
+ member = "wrapper_traits< " + mi.fq_type (false) + " >::" +
+ "set_ref (" + member + ")";
+ }
+
if (comp_value (mi.t))
traits = "composite_value_traits< " + mi.fq_type () + " >";
else
@@ -734,8 +759,10 @@ namespace relational
virtual void
traverse_composite (member_info& mi)
{
- os << traits << "::init (" << member << ", i." <<
- mi.var << "value, db);"
+ os << traits << "::init (" << endl
+ << member << "," << endl
+ << "i." << mi.var << "value," << endl
+ << "db);"
<< endl;
}
@@ -1065,7 +1092,8 @@ namespace relational
case ck_map:
case ck_multimap:
{
- if (semantics::class_* ktc = comp_value (container_kt (mt)))
+ if (semantics::class_* ktc =
+ comp_value_wrapper (container_kt (mt)))
{
instance<statement_oids> st;
st->traverse_composite (m, *ktc, "key", "key");
@@ -1083,7 +1111,7 @@ namespace relational
}
}
- if (semantics::class_* vtc = comp_value (vt))
+ if (semantics::class_* vtc = comp_value_wrapper (vt))
{
instance <statement_oids> st;
st->traverse_composite (m, *vtc, "value", "value");