Reflection of indexes in PostgreSQL doesn't preserve the order of columns
Issue #2767
resolved
Reflection of indexes in PostgreSQL returns columns in different order comparing to the one of original index. As order of columns in index definition does matter, this must be fixed.
Code to reproduce the bug:
import sqlalchemy as sa
eng = sa.create_engine('postgresql://test:test@localhost/test')
meta = sa.MetaData(bind=eng)
meta2 = sa.MetaData(bind=eng)
table = sa.Table(
'testtbl', meta,
sa.Column('a', sa.Integer),
sa.Column('b', sa.Integer),
sa.Column('c', sa.Integer),
sa.Index('test_idx', 'b', 'a', 'c')
)
meta.create_all()
table2 = sa.Table('testtbl', meta2, autoload=True)
idx = table2.indexes.pop()
assert idx.columns.keys() == ['a', 'c']('b',)
I'll provide the fix soon via pull request on GitHub
Comments (2)
-
repo owner -
repo owner - removed milestone
Removing milestone: 0.8.xx (automated comment)
- Log in to comment
master:
0333ee23d3fb88ed032ff61 ef6245a3caa10b0d1e1a
0.8:
59c01813adf01c75d fee954f2534eba6 699fdd4330879