def _get_index_final_name(dialect, idx):
if sqla_08:
+ # trying to keep the truncation rules totally localized on the
+ # SQLA side while also stepping around the quoting issue. Ideally
+ # the _prepared_index_name() method on the SQLA side would have
+ # a quoting option or the truncation routine would be broken out.
+ #
+ # test for SQLA quoted_name construct, introduced in
+ # 0.9 or thereabouts.
+ # this doesn't work in 0.8 and the "quote" option on Index doesn't
+ # seem to work in 0.8 either.
+ if hasattr(idx.name, "quote"):
+ # might be quoted_name, might be truncated_name, keep it the
+ # same
+ quoted_name_cls = type(idx.name)
+ new_name = quoted_name_cls(str(idx.name), quote=False)
+ idx = schema.Index(name=new_name)
return dialect.ddl_compiler(dialect, None)._prepared_index_name(idx)
else:
return idx.name
--- /dev/null
+.. change::
+ :tags: bug, autogenerate
+ :tickets: 472
+
+ Fixed regression caused by :ticket:`421` which would
+ cause case-sensitive quoting rules to interfere with the
+ comparison logic for index names, thus causing indexes to show
+ as added for indexes that have case-sensitive names. Works with
+ SQLAlchemy 0.9 and later series.
+
eq_(diffs, [])
+ # fails in the 0.8 series where we have truncation rules,
+ # but no control over quoting. passes in 0.7.9 where we don't have
+ # truncation rules either. dropping these ancient versions
+ # is long overdue.
+
+ @config.requirements.sqlalchemy_09
+ def test_unchanged_case_sensitive_implicit_idx(self):
+ m1 = MetaData()
+ m2 = MetaData()
+ Table('add_ix', m1, Column('regNumber', String(50), index=True))
+ Table('add_ix', m2, Column('regNumber', String(50), index=True))
+ diffs = self._fixture(m1, m2)
+
+ eq_(diffs, [])
+
+ @config.requirements.sqlalchemy_09
+ def test_unchanged_case_sensitive_explicit_idx(self):
+ m1 = MetaData()
+ m2 = MetaData()
+ t1 = Table('add_ix', m1, Column('reg_number', String(50)))
+ Index('regNumber_idx', t1.c.reg_number)
+ t2 = Table('add_ix', m2, Column('reg_number', String(50)))
+ Index('regNumber_idx', t2.c.reg_number)
+
+ diffs = self._fixture(m1, m2)
+
+ eq_(diffs, [])
+
class PGUniqueIndexTest(AutogenerateUniqueIndexTest):
reports_unnamed_constraints = True