From adfa9bbd04cd3571932ee7675344ca723bfa1eab Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 20 Jul 2012 14:26:23 +0200 Subject: Move indexes from model scope to table scope Conceptually, indexes belong to tables and some databases (MySQL, MSSQL) indeed treat them as such (i.e., you can have indexes with the same name in different tables). --- odb/relational/oracle/schema.cxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'odb/relational/oracle') diff --git a/odb/relational/oracle/schema.cxx b/odb/relational/oracle/schema.cxx index ce2c470..29c1130 100644 --- a/odb/relational/oracle/schema.cxx +++ b/odb/relational/oracle/schema.cxx @@ -302,6 +302,26 @@ namespace relational trav_rel::unames n (fk); names (t, n); } + + struct create_index: relational::create_index, context + { + create_index (base const& x): base (x) {} + + 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). + // + sema_rel::qname n ( + static_cast (in.scope ()).name ()); + + n.uname () += "_" + in.name (); + return quote_id (n); + } + }; + entry create_index_; } } } -- cgit v1.1