summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-09-30 20:00:46 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2012-09-30 20:00:46 +0000
commitbba1d01b26adb2db5b3c3fc41b94834cec5c73fc (patch)
tree8d8b78427343fe0afae089602adbea4b8bde60e2 /lib/sqlalchemy
parent0c3e2b49b99655edba28230a70622982faba7185 (diff)
downloadsqlalchemy-bba1d01b26adb2db5b3c3fc41b94834cec5c73fc.tar.gz
- [bug] The CreateIndex construct in Oracle
will now schema-qualify the name of the index to be that of the parent table. Previously this name was omitted which apparently creates the index in the default schema, rather than that of the table.
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/dialects/oracle/base.py4
-rw-r--r--lib/sqlalchemy/sql/compiler.py16
2 files changed, 15 insertions, 5 deletions
diff --git a/lib/sqlalchemy/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py
index 399f90035..c7cc6a7f9 100644
--- a/lib/sqlalchemy/dialects/oracle/base.py
+++ b/lib/sqlalchemy/dialects/oracle/base.py
@@ -631,6 +631,10 @@ class OracleDDLCompiler(compiler.DDLCompiler):
return text
+ def visit_create_index(self, create, **kw):
+ return super(OracleDDLCompiler, self).\
+ visit_create_index(create, include_schema=True)
+
class OracleIdentifierPreparer(compiler.IdentifierPreparer):
reserved_words = set([x.lower() for x in RESERVED_WORDS])
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index 1acd37f62..3b17c040c 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -1866,15 +1866,16 @@ class DDLCompiler(engine.Compiled):
return ident
- def visit_create_index(self, create):
+ def visit_create_index(self, create, include_schema=False):
index = create.element
preparer = self.preparer
text = "CREATE "
if index.unique:
text += "UNIQUE "
text += "INDEX %s ON %s (%s)" \
- % (preparer.quote(self._index_identifier(index.name),
- index.quote),
+ % (
+ self._prepared_index_name(index,
+ include_schema=include_schema),
preparer.format_table(index.table),
', '.join(preparer.quote(c.name, c.quote)
for c in index.columns))
@@ -1882,7 +1883,11 @@ class DDLCompiler(engine.Compiled):
def visit_drop_index(self, drop):
index = drop.element
- if index.table is not None and index.table.schema:
+ return "\nDROP INDEX " + self._prepared_index_name(index,
+ include_schema=True)
+
+ def _prepared_index_name(self, index, include_schema=False):
+ if include_schema and index.table is not None and index.table.schema:
schema = index.table.schema
schema_name = self.preparer.quote_schema(schema,
index.table.quote_schema)
@@ -1895,7 +1900,8 @@ class DDLCompiler(engine.Compiled):
if schema_name:
index_name = schema_name + "." + index_name
- return "\nDROP INDEX " + index_name
+ return index_name
+
def visit_add_constraint(self, create):
preparer = self.preparer