aboutsummaryrefslogtreecommitdiff
path: root/odb/context.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-08-01 11:16:20 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-08-01 11:16:20 +0200
commit4cde011f27cd406804f05aa8fd1d28ed91a26738 (patch)
treedc202095520894044a93e1ea5b8a9c30e84e4e25 /odb/context.cxx
parent4fcb4ae749b3cf40f24ab1b9ddeb58b3ae0600f7 (diff)
Add support for empty column names in composite value types
Diffstat (limited to 'odb/context.cxx')
-rw-r--r--odb/context.cxx30
1 files changed, 29 insertions, 1 deletions
diff --git a/odb/context.cxx b/odb/context.cxx
index 8335ec4..df94dfb 100644
--- a/odb/context.cxx
+++ b/odb/context.cxx
@@ -897,7 +897,7 @@ column_name (data_member_path const& mp) const
if (composite_wrapper (utype (m)))
r += object_columns_base::column_prefix (m);
else
- r += column_name (m);
+ r = compose_name (r, column_name (m));
}
return r;
@@ -928,6 +928,34 @@ column_name (semantics::data_member& m, string const& p, string const& d) const
}
string context::
+compose_name (string const& prefix, string const& name)
+{
+ string r (prefix);
+ size_t n (r.size ());
+
+ // Add an underscore unless one is already in the prefix or
+ // the name is empty. Similarly, remove it if it is there but
+ // the name is empty.
+ //
+ if (n != 0)
+ {
+ if (r[n - 1] != '_')
+ {
+ if (!name.empty ())
+ r += '_';
+ }
+ else
+ {
+ if (name.empty ())
+ r.resize (n - 1);
+ }
+ }
+
+ r += name;
+ return r;
+}
+
+string context::
column_type (const data_member_path& mp, string const& kp, bool id)
{
if (kp.empty ())