adding new content each time. [ticket:2566]
- sql
+ - [bug] Fixed the DropIndex construct to support
+ an Index associated with a Table in a remote
+ schema. [ticket:2571]
+
- [bug] Fixed CTE bug whereby positional
bound parameters present in the CTEs themselves
would corrupt the overall ordering of
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
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
from sqlalchemy.dialects.postgresql import base as postgresql
class ConstraintTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL):
+ __dialect__ = 'default'
def setup(self):
global metadata
Index, "foo", SomeClass()
)
+ def test_create_plain(self):
+ t = Table('t', MetaData(), Column('x', Integer))
+ i = Index("xyz", t.c.x)
+ self.assert_compile(
+ schema.CreateIndex(i),
+ "CREATE INDEX xyz ON t (x)"
+ )
+
+ def test_drop_plain_unattached(self):
+ self.assert_compile(
+ schema.DropIndex(Index(name="xyz")),
+ "DROP INDEX xyz"
+ )
+
+ def test_drop_plain(self):
+ t = Table('t', MetaData(), Column('x', Integer))
+ i = Index("xyz", t.c.x)
+ self.assert_compile(
+ schema.DropIndex(Index(name="xyz")),
+ "DROP INDEX xyz"
+ )
+
+ def test_create_schema(self):
+ t = Table('t', MetaData(), Column('x', Integer), schema="foo")
+ i = Index("xyz", t.c.x)
+ self.assert_compile(
+ schema.CreateIndex(i),
+ "CREATE INDEX xyz ON foo.t (x)"
+ )
+
+ def test_drop_schema(self):
+ t = Table('t', MetaData(), Column('x', Integer), schema="foo")
+ i = Index("xyz", t.c.x)
+ self.assert_compile(
+ schema.DropIndex(i),
+ "DROP INDEX foo.xyz"
+ )
+
class ConstraintCompilationTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = 'default'