diff options
author | Pete Hollobon <phollobon@renshawbay.com> | 2015-06-04 15:12:09 +0100 |
---|---|---|
committer | Pete Hollobon <phollobon@renshawbay.com> | 2015-06-04 15:12:09 +0100 |
commit | b03ee45f32e53416ce1c73fa15966db17ed4bbf9 (patch) | |
tree | f4b308a868841804adee29bfc508ac6e57101908 /lib/sqlalchemy/dialects/postgresql/base.py | |
parent | dff81500b161cf41ff5d9e77c21a24010e1bd93b (diff) | |
download | sqlalchemy-b03ee45f32e53416ce1c73fa15966db17ed4bbf9.tar.gz |
Add reflection of PostgreSQL index storage options
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index e0926a852..b9690e214 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -2624,7 +2624,8 @@ class PGDialect(default.DefaultDialect): SELECT i.relname as relname, ix.indisunique, ix.indexprs, ix.indpred, - a.attname, a.attnum, NULL, ix.indkey%s + a.attname, a.attnum, NULL, ix.indkey%s, + i.reloptions FROM pg_class t join pg_index ix on t.oid = ix.indrelid @@ -2651,7 +2652,8 @@ class PGDialect(default.DefaultDialect): SELECT i.relname as relname, ix.indisunique, ix.indexprs, ix.indpred, - a.attname, a.attnum, c.conrelid, ix.indkey::varchar + a.attname, a.attnum, c.conrelid, ix.indkey::varchar, + i.reloptions FROM pg_class t join pg_index ix on t.oid = ix.indrelid @@ -2680,7 +2682,7 @@ class PGDialect(default.DefaultDialect): sv_idx_name = None for row in c.fetchall(): - idx_name, unique, expr, prd, col, col_num, conrelid, idx_key = row + idx_name, unique, expr, prd, col, col_num, conrelid, idx_key, options = row if expr: if idx_name != sv_idx_name: @@ -2706,6 +2708,8 @@ class PGDialect(default.DefaultDialect): index['unique'] = unique if conrelid is not None: index['duplicates_constraint'] = idx_name + if options: + index['options'] = dict([option.split("=") for option in options]) result = [] for name, idx in indexes.items(): @@ -2716,6 +2720,8 @@ class PGDialect(default.DefaultDialect): } if 'duplicates_constraint' in idx: entry['duplicates_constraint'] = idx['duplicates_constraint'] + if 'options' in idx: + entry.setdefault('dialect_options', {})["postgresql_with"] = idx['options'] result.append(entry) return result |