diff options
| -rw-r--r-- | CHANGES | 6 | ||||
| -rw-r--r-- | lib/sqlalchemy/databases/postgres.py | 9 | ||||
| -rw-r--r-- | test/dialect/postgres.py | 11 |
3 files changed, 20 insertions, 6 deletions
@@ -32,7 +32,11 @@ CHANGES creates an arbitrarily large number of engines or dialects. There is a small performance penalty which will be resolved in 0.6. [ticket:1299] - + +- postgres + - Index reflection won't fail when an index with + multiple expressions is encountered. + 0.5.2 ====== diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 155b478af..8caadfaf8 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -638,10 +638,11 @@ class PGDialect(default.DefaultDialect): for row in c.fetchall(): idx_name, unique, expr, prd, col = row - if expr and not idx_name == sv_idx_name: - util.warn( - "Skipped unsupported reflection of expression-based index %s" - % idx_name) + if expr: + if not idx_name == sv_idx_name: + util.warn( + "Skipped unsupported reflection of expression-based index %s" + % idx_name) sv_idx_name = idx_name continue if prd and not idx_name == sv_idx_name: diff --git a/test/dialect/postgres.py b/test/dialect/postgres.py index 206a28003..4b1ab9178 100644 --- a/test/dialect/postgres.py +++ b/test/dialect/postgres.py @@ -631,15 +631,23 @@ class MiscTest(TestBase, AssertsExecutionResults): m1 = MetaData(testing.db) t1 = Table('party', m1, Column('id', String(10), nullable=False), - Column('name', String(20), index=True) + Column('name', String(20), index=True), + Column('aname', String(20)) ) m1.create_all() + testing.db.execute(""" create index idx1 on party ((id || name)) """, None) testing.db.execute(""" create unique index idx2 on party (id) where name = 'test' """, None) + + testing.db.execute(""" + create index idx3 on party using btree + (lower(name::text), lower(aname::text)) + """) + try: m2 = MetaData(testing.db) @@ -655,6 +663,7 @@ class MiscTest(TestBase, AssertsExecutionResults): # Make sure indexes are in the order we expect them in tmp = [(idx.name, idx) for idx in t2.indexes] tmp.sort() + r1, r2 = [idx[1] for idx in tmp] assert r1.name == 'idx2' |
