From ef0da7eb66d173a487adbee96311bf4996da0556 Mon Sep 17 00:00:00 2001 From: beenje Date: Mon, 11 Apr 2016 23:15:35 -0400 Subject: Add postgresql_tablespace option on Index This complements the same-named parameter available on Table. Fixes: #3720 Change-Id: I56e081e2a551f37c3f392ca4b301c9ef82b94e59 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/233 --- test/dialect/postgresql/test_compiler.py | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'test/dialect/postgresql/test_compiler.py') diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index 87e48d3f2..c20e48b01 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -412,6 +412,49 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): 'USING gist (data) ' 'WITH (buffering = off)') + def test_create_index_with_tablespace(self): + m = MetaData() + tbl = Table('testtbl', m, Column('data', String)) + + idx1 = Index('test_idx1', tbl.c.data) + idx2 = Index('test_idx2', tbl.c.data, postgresql_tablespace='sometablespace') + idx3 = Index('test_idx3', tbl.c.data, postgresql_tablespace='another table space') + + self.assert_compile(schema.CreateIndex(idx1), + 'CREATE INDEX test_idx1 ON testtbl ' + '(data)', + dialect=postgresql.dialect()) + self.assert_compile(schema.CreateIndex(idx2), + 'CREATE INDEX test_idx2 ON testtbl ' + '(data) ' + 'TABLESPACE sometablespace', + dialect=postgresql.dialect()) + self.assert_compile(schema.CreateIndex(idx3), + 'CREATE INDEX test_idx3 ON testtbl ' + '(data) ' + 'TABLESPACE "another table space"', + dialect=postgresql.dialect()) + + def test_create_index_with_multiple_options(self): + m = MetaData() + tbl = Table('testtbl', m, Column('data', String)) + + idx1 = Index( + 'test_idx1', + tbl.c.data, + postgresql_using='btree', + postgresql_tablespace='atablespace', + postgresql_with={"fillfactor": 60}, + postgresql_where=and_(tbl.c.data > 5, tbl.c.data < 10)) + + self.assert_compile(schema.CreateIndex(idx1), + 'CREATE INDEX test_idx1 ON testtbl ' + 'USING btree (data) ' + 'WITH (fillfactor = 60) ' + 'TABLESPACE atablespace ' + 'WHERE data > 5 AND data < 10', + dialect=postgresql.dialect()) + def test_create_index_expr_gets_parens(self): m = MetaData() tbl = Table('testtbl', m, Column('x', Integer), Column('y', Integer)) -- cgit v1.2.1