summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-09-24 11:17:16 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-09-24 11:17:16 -0400
commitc7c17e991cc53d201c8bb1e787efc313bebe8d4a (patch)
treeebc9ef7a77d1e31a1bc732d344e8c49b37a5a8f9 /lib
parent4af7743ce70bce50a8630ba91060101fc941281c (diff)
downloadsqlalchemy-c7c17e991cc53d201c8bb1e787efc313bebe8d4a.tar.gz
- [bug] Fixed the DropIndex construct to support
an Index associated with a Table in a remote schema. [ticket:2571]
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/sql/compiler.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index 8a7f05eb3..1acd37f62 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -1859,13 +1859,12 @@ class DDLCompiler(engine.Compiled):
max = self.dialect.max_index_name_length or \
self.dialect.max_identifier_length
if len(ident) > max:
- return ident[0:max - 8] + \
+ ident = ident[0:max - 8] + \
"_" + util.md5_hex(ident)[-4:]
- else:
- return ident
else:
self.dialect.validate_identifier(ident)
- return ident
+
+ return ident
def visit_create_index(self, create):
index = create.element
@@ -1883,9 +1882,20 @@ class DDLCompiler(engine.Compiled):
def visit_drop_index(self, drop):
index = drop.element
- return "\nDROP INDEX " + \
- self.preparer.quote(
- self._index_identifier(index.name), index.quote)
+ if index.table is not None and index.table.schema:
+ schema = index.table.schema
+ schema_name = self.preparer.quote_schema(schema,
+ index.table.quote_schema)
+ else:
+ schema_name = None
+
+ index_name = self.preparer.quote(
+ self._index_identifier(index.name),
+ index.quote)
+
+ if schema_name:
+ index_name = schema_name + "." + index_name
+ return "\nDROP INDEX " + index_name
def visit_add_constraint(self, create):
preparer = self.preparer