summaryrefslogtreecommitdiff
path: root/odb
diff options
context:
space:
mode:
Diffstat (limited to 'odb')
-rw-r--r--odb/context.cxx23
-rw-r--r--odb/options.cli10
2 files changed, 28 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::
diff --git a/odb/options.cli b/odb/options.cli
index 34c35a6..65c9873 100644
--- a/odb/options.cli
+++ b/odb/options.cli
@@ -142,6 +142,16 @@ class options
profile."
};
+ std::string --table-prefix
+ {
+ "<prefix>",
+ "Add <prefix> to table and index names. The prefix is added to both
+ names that were specified with the \cb{db table} pragma and those
+ that were automatically derived from class names. If you require a
+ separator, such as an underscore, between the prefix and the name,
+ then you should include it into the prefix value."
+ };
+
std::string --output-dir | -o
{
"<dir>",