diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-08-24 17:51:48 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-08-24 17:51:48 +0200 |
commit | de130e93d8b2c026732211e67b6f31157f1b7e87 (patch) | |
tree | 898f6bf3f0029565654b044df057789097c86ab0 /odb/context.cxx | |
parent | 15995637f9cab6a4d92a2383e2afdba2b48d5f7b (diff) |
Fix inconsistent composite value member prefix derivation
Diffstat (limited to 'odb/context.cxx')
-rw-r--r-- | odb/context.cxx | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/odb/context.cxx b/odb/context.cxx index 6dcf987..e8dd96a 100644 --- a/odb/context.cxx +++ b/odb/context.cxx @@ -2133,7 +2133,7 @@ table_name (semantics::data_member& m, table_prefix const& p) const // context::column_prefix:: column_prefix (data_member_path const& mp, bool l) - : derived (false) + : derived (false), underscore (false) { if (mp.size () < (l ? 1 : 2)) return; @@ -2157,12 +2157,16 @@ append (semantics::data_member& m, string const& kp, string const& dn) // If the user provided the column prefix, then use it verbatime. // Otherwise, append the underscore, unless it is already there. // + underscore = false; if (d) { size_t n (prefix.size ()); if (n != 0 && prefix[n - 1] != '_') + { prefix += '_'; + underscore = true; + } } derived = derived || d; @@ -2181,8 +2185,13 @@ string context:: column_name (semantics::data_member& m, column_prefix const& cp) const { bool d; - string n (column_name (m, d)); - n = compose_name (cp.prefix, n); + const string& cn (column_name (m, d)); + string n (cp.prefix); + + if (cn.empty () && cp.underscore) + n.resize (n.size () - 1); // Strip underscore that was auto added. + + n += cn; // If any component is derived, then run it through the SQL name regex. // @@ -2228,8 +2237,13 @@ column_name (semantics::data_member& m, column_prefix const& cp) const { bool d; - string n (column_name (m, kp, dn, d)); - n = compose_name (cp.prefix, n); + const string& cn (column_name (m, kp, dn, d)); + string n (cp.prefix); + + if (cn.empty () && cp.underscore) + n.resize (n.size () - 1); // Strip underscore that was auto-added. + + n += cn; // If any component is derived, the run it through the SQL name regex. // |