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/oracle/schema.cxx | |
parent | 2ad2e5500dd075db421a516502c9e522fdc34ee0 (diff) |
Add support for SQL name transformations
Diffstat (limited to 'odb/relational/oracle/schema.cxx')
-rw-r--r-- | odb/relational/oracle/schema.cxx | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/odb/relational/oracle/schema.cxx b/odb/relational/oracle/schema.cxx index f07e0d6..ffe4b31 100644 --- a/odb/relational/oracle/schema.cxx +++ b/odb/relational/oracle/schema.cxx @@ -127,7 +127,7 @@ namespace relational { os << " BEGIN" << endl << " EXECUTE IMMEDIATE 'DROP SEQUENCE " << - quote_id (table + "_seq") << "';" << endl + quote_id (sequence_name (table)) << "';" << endl << " EXCEPTION" << endl << " WHEN OTHERS THEN" << endl << " IF SQLCODE != -2289 THEN RAISE; END IF;" << endl @@ -184,18 +184,6 @@ namespace relational fk.set ("oracle-fk-defined", true); // Mark it as defined. } } - - virtual string - name (sema_rel::foreign_key& fk) - { - // In Oracle, foreign key names are schema-global. Make them - // unique by prefixing the key name with table name. Note, - // however, that they cannot have a schema. - // - return quote_id ( - static_cast<sema_rel::table&> (fk.scope ()).name ().uname () - + "_" + fk.name ()); - } }; entry<create_foreign_key> create_foreign_key_; @@ -244,7 +232,8 @@ namespace relational if (pk != 0 && pk->auto_ ()) { pre_statement (); - os_ << "CREATE SEQUENCE " << quote_id (t.name () + "_seq") << endl + os_ << "CREATE SEQUENCE " << + quote_id (sequence_name (t.name ())) << endl << " START WITH 1 INCREMENT BY 1" << endl; post_statement (); } @@ -266,14 +255,11 @@ namespace relational virtual string name (sema_rel::index& in) { - // In Oracle, index names are database-global. Make them unique - // by prefixing the index name with table name (preserving the - // schema). + // In Oracle, index names can be qualified with the schema. // - sema_rel::qname n ( - static_cast<sema_rel::table&> (in.scope ()).name ()); - - n.uname () += "_" + in.name (); + sema_rel::table& t (static_cast<sema_rel::table&> (in.scope ())); + sema_rel::qname n (t.name ().qualifier ()); + n.append (in.name ()); return quote_id (n); } }; |