diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-11-09 20:19:17 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-11-09 20:19:17 +0200 |
commit | 9072761e0c9486cc3d1265a1c1e2b39db8e68bf7 (patch) | |
tree | 1e284d8088e51a962bd285b02f8096ed088463ee /odb/relational/pgsql | |
parent | dfba83f1ef3b5856d36dc29da0b6e02f51bc36b3 (diff) |
Make sure we can use same type as both container and simple value
Diffstat (limited to 'odb/relational/pgsql')
-rw-r--r-- | odb/relational/pgsql/common.cxx | 9 | ||||
-rw-r--r-- | odb/relational/pgsql/common.hxx | 8 | ||||
-rw-r--r-- | odb/relational/pgsql/header.cxx | 2 | ||||
-rw-r--r-- | odb/relational/pgsql/source.cxx | 10 |
4 files changed, 20 insertions, 9 deletions
diff --git a/odb/relational/pgsql/common.cxx b/odb/relational/pgsql/common.cxx index 4993408..e2d619e 100644 --- a/odb/relational/pgsql/common.cxx +++ b/odb/relational/pgsql/common.cxx @@ -33,9 +33,10 @@ namespace relational var = name + (name[name.size () - 1] == '_' ? "" : "_"); } - bool cq (type_override_ != 0 ? false: const_type (m.type ())); + bool cq (type_override_ != 0 ? false : const_type (m.type ())); semantics::type& t (type_override_ != 0 ? *type_override_ : utype (m)); + semantics::type* cont; if (semantics::class_* c = composite_wrapper (t)) { // If t is a wrapper, pass the wrapped type. Also pass the @@ -53,12 +54,14 @@ namespace relational post (mi); } } - else if (semantics::type* c = container_wrapper (t)) + // This cannot be a container if we have a type override. + // + else if (type_override_ == 0 && (cont = context::container (m))) { // The same unwrapping logic as for composite values. // member_info mi (m, - *c, + *cont, (wrapper (t) ? &t : 0), cq, var, diff --git a/odb/relational/pgsql/common.hxx b/odb/relational/pgsql/common.hxx index 7a92a4a..e62bd1c 100644 --- a/odb/relational/pgsql/common.hxx +++ b/odb/relational/pgsql/common.hxx @@ -88,6 +88,14 @@ namespace relational } }; + bool + container (member_info& mi) + { + // This cannot be a container if we have a type override. + // + return type_override_ == 0 && context::container (mi.m); + } + // The false return value indicates that no further callbacks // should be called for this member. // diff --git a/odb/relational/pgsql/header.cxx b/odb/relational/pgsql/header.cxx index db7a939..698dd31 100644 --- a/odb/relational/pgsql/header.cxx +++ b/odb/relational/pgsql/header.cxx @@ -130,7 +130,7 @@ namespace relational virtual bool pre (member_info& mi) { - if (container (mi.t)) + if (container (mi)) return false; image_type = member_image_type_.image_type (mi.m); diff --git a/odb/relational/pgsql/source.cxx b/odb/relational/pgsql/source.cxx index 0ff0bf1..7200405 100644 --- a/odb/relational/pgsql/source.cxx +++ b/odb/relational/pgsql/source.cxx @@ -154,7 +154,7 @@ namespace relational virtual bool pre (member_info& mi) { - if (container (mi.t)) + if (container (mi)) return false; ostringstream ostr; @@ -364,7 +364,7 @@ namespace relational virtual bool pre (member_info& mi) { - if (container (mi.t)) + if (container (mi)) return false; ostringstream ostr; @@ -490,7 +490,7 @@ namespace relational // Ignore containers (they get their own table) and inverse // object pointers (they are not present in this binding). // - if (container (mi.t) || inverse (mi.m, key_prefix_)) + if (container (mi) || inverse (mi.m, key_prefix_)) return false; if (!member_override_.empty ()) @@ -756,7 +756,7 @@ namespace relational virtual bool pre (member_info& mi) { - if (container (mi.t)) + if (container (mi)) return false; if (!member_override_.empty ()) @@ -1268,7 +1268,7 @@ namespace relational { // many(i)-to-many // - if (container_wrapper (utype (*inv_m))) + if (container (*inv_m)) os << oids[column_sql_type (*inv_m, "value").type]; // many(i)-to-one |