aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odb/common.cxx4
-rw-r--r--odb/context.cxx10
-rw-r--r--odb/context.hxx37
-rw-r--r--odb/relational/mysql/common.cxx9
-rw-r--r--odb/relational/mysql/common.hxx8
-rw-r--r--odb/relational/mysql/header.cxx2
-rw-r--r--odb/relational/mysql/source.cxx8
-rw-r--r--odb/relational/oracle/common.cxx9
-rw-r--r--odb/relational/oracle/common.hxx8
-rw-r--r--odb/relational/oracle/header.cxx2
-rw-r--r--odb/relational/oracle/source.cxx6
-rw-r--r--odb/relational/pgsql/common.cxx9
-rw-r--r--odb/relational/pgsql/common.hxx8
-rw-r--r--odb/relational/pgsql/header.cxx2
-rw-r--r--odb/relational/pgsql/source.cxx10
-rw-r--r--odb/relational/source.cxx6
-rw-r--r--odb/relational/source.hxx15
-rw-r--r--odb/relational/sqlite/common.cxx9
-rw-r--r--odb/relational/sqlite/common.hxx8
-rw-r--r--odb/relational/sqlite/header.cxx2
-rw-r--r--odb/relational/sqlite/source.cxx8
21 files changed, 111 insertions, 69 deletions
diff --git a/odb/common.cxx b/odb/common.cxx
index 27b647c..322a915 100644
--- a/odb/common.cxx
+++ b/odb/common.cxx
@@ -208,7 +208,7 @@ traverse (semantics::data_member& m)
om_.member_scope_.pop_back ();
}
- else if (semantics::type* c = context::container_wrapper (t))
+ else if (semantics::type* c = context::container (m))
{
om_.traverse_container (m, *c);
}
@@ -426,7 +426,7 @@ traverse (semantics::data_member& m)
oc_.member_scope_.pop_back ();
}
- else if (container_wrapper (t))
+ else if (container (m))
{
// Container gets its own table, so nothing to do here.
//
diff --git a/odb/context.cxx b/odb/context.cxx
index 9842a22..532a6b7 100644
--- a/odb/context.cxx
+++ b/odb/context.cxx
@@ -1192,19 +1192,17 @@ is_a (data_member_path const& mp,
test_inverse_container |
test_readonly_container)) != 0)
{
- semantics::type& c (utype (m));
-
if (f & test_container)
- r = r || container_wrapper (c);
+ r = r || container (m);
if (f & test_straight_container)
- r = r || (container_wrapper (c) && !inverse (m, kp));
+ r = r || (container(m) && !inverse (m, kp));
if (f & test_inverse_container)
- r = r || (container_wrapper (c) && inverse (m, kp));
+ r = r || (container (m) && inverse (m, kp));
if (f & test_readonly_container)
- r = r || (container_wrapper (c) && readonly (mp, ms));
+ r = r || (container (m) && readonly (mp, ms));
}
return r;
diff --git a/odb/context.hxx b/odb/context.hxx
index 10210a3..3be05a9 100644
--- a/odb/context.hxx
+++ b/odb/context.hxx
@@ -333,27 +333,28 @@ public:
return 0;
}
- static bool
- container (semantics::type& t)
- {
- return t.count ("container-kind");
- }
-
- // As above but also "sees through" wrappers. Returns the actual
- // container type or NULL if not a container.
+ // Check if a data member is a container. "Sees through" wrappers and
+ // returns the actual container type or NULL if not a container.
+ //
+ // We require data member as input instead of the type because the
+ // same type (e.g., vector<char>) can be used for both container
+ // and simple value members.
//
static semantics::type*
- container_wrapper (semantics::type& t)
+ container (semantics::data_member& m)
{
- if (container (t))
- return &t;
- else if (semantics::type* wt = wrapper (t))
- {
- wt = &utype (*wt);
- return container (*wt) ? wt : 0;
- }
- else
+ // The same type can be used as both a container and a simple value.
+ // If the member has defines the database type, then it is the latter.
+ //
+ if (m.count ("type") || m.count ("id-type"))
return 0;
+
+ semantics::type* t (&utype (m));
+
+ if (semantics::type* wt = wrapper (*t))
+ t = &utype (*wt);
+
+ return t->count ("container-kind") ? t : 0;
}
static semantics::class_*
@@ -620,7 +621,7 @@ public:
if (m.count ("unordered"))
return true;
- if (semantics::type* c = container_wrapper (utype (m)))
+ if (semantics::type* c = container (m))
return c->count ("unordered");
return false;
diff --git a/odb/relational/mysql/common.cxx b/odb/relational/mysql/common.cxx
index 4c66254..f7486cd 100644
--- a/odb/relational/mysql/common.cxx
+++ b/odb/relational/mysql/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/mysql/common.hxx b/odb/relational/mysql/common.hxx
index 66269c6..617bc73 100644
--- a/odb/relational/mysql/common.hxx
+++ b/odb/relational/mysql/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/mysql/header.cxx b/odb/relational/mysql/header.cxx
index 5abb241..04b7d76 100644
--- a/odb/relational/mysql/header.cxx
+++ b/odb/relational/mysql/header.cxx
@@ -31,7 +31,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/mysql/source.cxx b/odb/relational/mysql/source.cxx
index 6a05878..576f80c 100644
--- a/odb/relational/mysql/source.cxx
+++ b/odb/relational/mysql/source.cxx
@@ -183,7 +183,7 @@ namespace relational
virtual bool
pre (member_info& mi)
{
- if (container (mi.t))
+ if (container (mi))
return false;
ostringstream ostr;
@@ -428,7 +428,7 @@ namespace relational
virtual bool
pre (member_info& mi)
{
- if (container (mi.t))
+ if (container (mi))
return false;
ostringstream ostr;
@@ -580,7 +580,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 ())
@@ -872,7 +872,7 @@ namespace relational
virtual bool
pre (member_info& mi)
{
- if (container (mi.t))
+ if (container (mi))
return false;
if (!member_override_.empty ())
diff --git a/odb/relational/oracle/common.cxx b/odb/relational/oracle/common.cxx
index 7104876..b253dc3 100644
--- a/odb/relational/oracle/common.cxx
+++ b/odb/relational/oracle/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/oracle/common.hxx b/odb/relational/oracle/common.hxx
index 0aa5419..d2799cb 100644
--- a/odb/relational/oracle/common.hxx
+++ b/odb/relational/oracle/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/oracle/header.cxx b/odb/relational/oracle/header.cxx
index 7c26a6d..5d13d41 100644
--- a/odb/relational/oracle/header.cxx
+++ b/odb/relational/oracle/header.cxx
@@ -62,7 +62,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/oracle/source.cxx b/odb/relational/oracle/source.cxx
index f362d5b..68cd367 100644
--- a/odb/relational/oracle/source.cxx
+++ b/odb/relational/oracle/source.cxx
@@ -76,7 +76,7 @@ namespace relational
virtual bool
pre (member_info& mi)
{
- if (container (mi.t))
+ if (container (mi))
return false;
ostringstream ostr;
@@ -356,7 +356,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 ())
@@ -641,7 +641,7 @@ namespace relational
virtual bool
pre (member_info& mi)
{
- if (container (mi.t))
+ if (container (mi))
return false;
if (!member_override_.empty ())
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
diff --git a/odb/relational/source.cxx b/odb/relational/source.cxx
index be16309..749e0d6 100644
--- a/odb/relational/source.cxx
+++ b/odb/relational/source.cxx
@@ -259,10 +259,12 @@ namespace relational
{
using semantics::type;
- type* t (&context::utype (*m));
+ type* t;
- if (type* c = context::container_wrapper (*t))
+ if (type* c = context::container (*m))
t = &context::container_vt (*c);
+ else
+ t = &context::utype (*m);
if (context::object_pointer (*t))
return e;
diff --git a/odb/relational/source.hxx b/odb/relational/source.hxx
index cabb5c5..7961636 100644
--- a/odb/relational/source.hxx
+++ b/odb/relational/source.hxx
@@ -107,7 +107,7 @@ namespace relational
{
semantics::class_* c (object_pointer (utype (m)));
- if (container_wrapper (utype (*im)))
+ if (container (*im))
{
// This container is a direct member of the class so the table
// prefix is just the class table name. We don't assign join
@@ -425,7 +425,7 @@ namespace relational
if (semantics::data_member* im = inverse (m))
{
- if (container_wrapper (utype (*im)))
+ if (container (*im))
{
// This container is a direct member of the class so the table
// prefix is just the class table name.
@@ -937,7 +937,7 @@ namespace relational
string inv_id; // Other id column.
string inv_fid; // Other foreign id column (ref to us).
- if (container_wrapper (utype (*im)))
+ if (container (*im))
{
// many(i)-to-many
//
@@ -3820,12 +3820,11 @@ namespace relational
// some sanity checks while at it.
//
semantics::class_* c (0);
- semantics::type& t (utype (m));
- if (semantics::type* cont = container_wrapper (t))
+ if (semantics::type* cont = container (m))
c = object_pointer (container_vt (*cont));
else
- c = object_pointer (t);
+ c = object_pointer (utype (m));
view_object const* vo (0);
@@ -3909,9 +3908,7 @@ namespace relational
//
data_member* im (inverse (m));
- semantics::type* cont (
- container_wrapper (
- utype (im != 0 ? *im : m)));
+ semantics::type* cont (container (im != 0 ? *im : m));
// Container table.
//
diff --git a/odb/relational/sqlite/common.cxx b/odb/relational/sqlite/common.cxx
index 357fb87..e3bf73c 100644
--- a/odb/relational/sqlite/common.cxx
+++ b/odb/relational/sqlite/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/sqlite/common.hxx b/odb/relational/sqlite/common.hxx
index c998607..3bdc01e 100644
--- a/odb/relational/sqlite/common.hxx
+++ b/odb/relational/sqlite/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/sqlite/header.cxx b/odb/relational/sqlite/header.cxx
index 87faf20..1a2db32 100644
--- a/odb/relational/sqlite/header.cxx
+++ b/odb/relational/sqlite/header.cxx
@@ -31,7 +31,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/sqlite/source.cxx b/odb/relational/sqlite/source.cxx
index 041f8aa..32ac13e 100644
--- a/odb/relational/sqlite/source.cxx
+++ b/odb/relational/sqlite/source.cxx
@@ -34,7 +34,7 @@ namespace relational
virtual bool
pre (member_info& mi)
{
- if (container (mi.t))
+ if (container (mi))
return false;
ostringstream ostr;
@@ -203,7 +203,7 @@ namespace relational
virtual bool
pre (member_info& mi)
{
- if (container (mi.t))
+ if (container (mi))
return false;
ostringstream ostr;
@@ -288,7 +288,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 ())
@@ -498,7 +498,7 @@ namespace relational
virtual bool
pre (member_info& mi)
{
- if (container (mi.t))
+ if (container (mi))
return false;
if (!member_override_.empty ())