diff options
author | Pete Hollobon <phollobon@renshawbay.com> | 2015-06-03 16:55:58 +0100 |
---|---|---|
committer | Pete Hollobon <phollobon@renshawbay.com> | 2015-06-03 17:32:12 +0100 |
commit | dff81500b161cf41ff5d9e77c21a24010e1bd93b (patch) | |
tree | 44161e757cb78b663c98c9ea084eb647accd245d /lib/sqlalchemy/dialects/postgresql/base.py | |
parent | 16a87fe6d954def3143820217adf398d8eda42c9 (diff) | |
download | sqlalchemy-dff81500b161cf41ff5d9e77c21a24010e1bd93b.tar.gz |
Add support for PostgreSQL index storage parameters
Add support for specifying PostgreSQL index storage paramters (e.g.
fillfactor).
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 73fe5022a..e0926a852 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -401,6 +401,15 @@ The value passed to the keyword argument will be simply passed through to the underlying CREATE INDEX command, so it *must* be a valid index type for your version of PostgreSQL. +Index Storage Parameters +^^^^^^^^^^^^^^^^^^^^^^^^ + +PostgreSQL allows storage parameters to be set on indexes. The storage +parameters available depend on the index method used by the index. Storage +parameters can be specified on :class:`.Index` using the ``postgresql_with`` +keyword argument:: + + Index('my_index', my_table.c.data, postgresql_with={"fillfactor": 50}) .. _postgresql_index_concurrently: @@ -1592,6 +1601,13 @@ class PGDDLCompiler(compiler.DDLCompiler): ]) ) + withclause = index.dialect_options['postgresql']['with'] + + if withclause: + text += " WITH (%s)" % (', '.join( + ['%s = %s' % storage_parameter + for storage_parameter in withclause.items()])) + whereclause = index.dialect_options["postgresql"]["where"] if whereclause is not None: @@ -1919,6 +1935,7 @@ class PGDialect(default.DefaultDialect): "where": None, "ops": {}, "concurrently": False, + "with": {} }), (schema.Table, { "ignore_search_path": False, |