diff options
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index fe3d29450..136cb1b28 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -414,6 +414,16 @@ keyword argument:: .. versionadded:: 1.0.6 +PostgreSQL allows to define the tablespace in which to create the index. +The tablespace can be specified on :class:`.Index` using the +``postgresql_tablespace`` keyword argument:: + + Index('my_index', my_table.c.data, postgresql_tablespace='my_tablespace') + +.. versionadded:: 1.1 + +Note that the same option is available on :class:`.Table` as well. + .. _postgresql_index_concurrently: Indexes with CONCURRENTLY @@ -482,6 +492,8 @@ dialect in conjunction with the :class:`.Table` construct: Table("some_table", metadata, ..., postgresql_tablespace='some_tablespace') + The above option is also available on the :class:`.Index` construct. + * ``ON COMMIT``:: Table("some_table", metadata, ..., postgresql_on_commit='PRESERVE ROWS') @@ -1294,6 +1306,11 @@ class PGDDLCompiler(compiler.DDLCompiler): ['%s = %s' % storage_parameter for storage_parameter in withclause.items()])) + tablespace_name = index.dialect_options['postgresql']['tablespace'] + + if tablespace_name: + text += " TABLESPACE %s" % preparer.quote(tablespace_name) + whereclause = index.dialect_options["postgresql"]["where"] if whereclause is not None: @@ -1631,7 +1648,8 @@ class PGDialect(default.DefaultDialect): "where": None, "ops": {}, "concurrently": False, - "with": {} + "with": {}, + "tablespace": None }), (schema.Table, { "ignore_search_path": False, |