From a94dde17a2e6a41c36dd052bc8d2bbbc224aeb97 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 22 Aug 2011 09:21:32 +0200 Subject: Add --table-prefix option Assign unique table prefixes to most examples. This makes sure that we don't end up with broken schemas where half of the tables were changed by the next test and the other half has foreign keys that now point to nowhere. --- odb/context.cxx | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'odb/context.cxx') diff --git a/odb/context.cxx b/odb/context.cxx index 0280c28..68e3f65 100644 --- a/odb/context.cxx +++ b/odb/context.cxx @@ -359,25 +359,38 @@ comp_value_ (semantics::class_& c) string context:: table_name (semantics::class_& t) const { + string name (options.table_prefix ()); + if (t.count ("table")) - return t.get ("table"); + name += t.get ("table"); else - return t.name (); + name += t.name (); + + return name; } string context:: table_name (semantics::data_member& m, table_prefix const& p) const { + string name (options.table_prefix ()); + // If a custom table name was specified, then ignore the top-level // table prefix. // if (m.count ("table")) { - string const& name (m.get ("table")); - return p.level == 1 ? name : p.prefix + name; + if (p.level != 1) + name += p.prefix; + + name += m.get ("table"); + } + else + { + name += p.prefix; + name += public_name_db (m); } - return p.prefix + public_name_db (m); + return name; } string context:: -- cgit v1.1