aboutsummaryrefslogtreecommitdiff
path: root/odb/context.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-08-22 09:21:32 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-08-22 09:21:32 +0200
commita94dde17a2e6a41c36dd052bc8d2bbbc224aeb97 (patch)
tree959aa2b294025aa41229dafb885c8d740eb70c0d /odb/context.cxx
parent6a6095112daabd18d445ecf0d4c05e993e54236c (diff)
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.
Diffstat (limited to 'odb/context.cxx')
-rw-r--r--odb/context.cxx23
1 files changed, 18 insertions, 5 deletions
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<string> ("table");
+ name += t.get<string> ("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<string> ("table"));
- return p.level == 1 ? name : p.prefix + name;
+ if (p.level != 1)
+ name += p.prefix;
+
+ name += m.get<string> ("table");
+ }
+ else
+ {
+ name += p.prefix;
+ name += public_name_db (m);
}
- return p.prefix + public_name_db (m);
+ return name;
}
string context::