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
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
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:
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():
}
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
eq_(ind, [{'unique': False, 'column_names': ['y'], 'name': 'idx1'}])
conn.close()
+ @testing.provide_metadata
+ def test_index_reflection_with_storage_options(self):
+ """reflect indexes with storage options set"""
+
+ metadata = self.metadata
+
+ t1 = Table('t', metadata,
+ Column('id', Integer, primary_key=True),
+ Column('x', Integer)
+ )
+ metadata.create_all()
+ conn = testing.db.connect().execution_options(autocommit=True)
+ conn.execute("CREATE INDEX idx1 ON t (x) WITH (fillfactor = 50)")
+
+ ind = testing.db.dialect.get_indexes(conn, "t", None)
+ eq_(ind, [{'unique': False, 'column_names': ['x'], 'name': 'idx1',
+ 'dialect_options': {"postgresql_with": {"fillfactor": "50"}}}])
+ conn.close()
+
+
@testing.provide_metadata
def test_foreign_key_option_inspection(self):
metadata = self.metadata