[Sqlalchemy-tickets] [sqlalchemy] #2767: Reflection of indexes in PostgreSQL doesn't preserve the o
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-06-26 05:27:18
|
#2767: Reflection of indexes in PostgreSQL doesn't preserve the order of columns
--------------------------------+---------------------------------------
Reporter: malor | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone:
Component: postgres | Severity: minor - half an hour
Keywords: reflection,indexes | Progress State: needs review
--------------------------------+---------------------------------------
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() == ['b', 'a', 'c']
}}}
I'll provide the fix soon via pull request on GitHub
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2767>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|