diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-12-12 11:26:44 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-12-12 11:26:44 +0200 |
commit | a5f24411433aeb61ad015129354a664820affab0 (patch) | |
tree | 25fb5a97c0c070b78c9318f1da3dcbc484785918 /odb/relational/context.cxx | |
parent | 2ad2e5500dd075db421a516502c9e522fdc34ee0 (diff) |
Add support for SQL name transformations
Diffstat (limited to 'odb/relational/context.cxx')
-rw-r--r-- | odb/relational/context.cxx | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/odb/relational/context.cxx b/odb/relational/context.cxx index 08e68e5..b484ad9 100644 --- a/odb/relational/context.cxx +++ b/odb/relational/context.cxx @@ -28,6 +28,8 @@ namespace relational insert_send_auto_id (current ().insert_send_auto_id), delay_freeing_statement_result (current ().delay_freeing_statement_result), need_image_clone (current ().need_image_clone), + global_index (current ().global_index), + global_fkey (current ().global_fkey), bind_vector (data_->bind_vector_), truncated_vector (data_->truncated_vector_) { @@ -45,6 +47,46 @@ namespace relational } string context:: + index_name (qname const& table, string const& base) + { + string n; + + if (options.index_suffix ().count (db) != 0) + n = base + options.index_suffix ()[db]; + else + n = compose_name (base, "i"); + + // If this database has global index names, then add the table + // name as a prefix (the schema, if needed, will be added by + // database-specific create_index overrides). + // + if (global_index) + n = compose_name (table.uname (), n); + + return transform_name (n, sql_name_index); + } + + string context:: + fkey_name (qname const& table, string const& base) + { + string n; + + if (options.fkey_suffix ().count (db) != 0) + n = base + options.fkey_suffix ()[db]; + else + n = compose_name (base, "fk"); + + // If this database has global index names, then add the table + // name as a prefix (the schema, if needed, will be added by + // database-specific create_foreign_key overrides). + // + if (global_fkey) + n = compose_name (table.uname (), n); + + return transform_name (n, sql_name_fkey); + } + + string context:: convert (string const& e, string const& c) { size_t p (c.find ("(?)")); |