summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_compiler.py
diff options
context:
space:
mode:
authorbeenje <beenje@gmail.org>2016-04-11 23:15:35 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2016-06-01 17:20:41 -0400
commitef0da7eb66d173a487adbee96311bf4996da0556 (patch)
treeba87f3817e332b17a9bf958b602bc99a867afe42 /test/dialect/postgresql/test_compiler.py
parenta8e7bb8782ca8fd858ac036082104b4ac2991cfc (diff)
downloadsqlalchemy-ef0da7eb66d173a487adbee96311bf4996da0556.tar.gz
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
Diffstat (limited to 'test/dialect/postgresql/test_compiler.py')
-rw-r--r--test/dialect/postgresql/test_compiler.py43
1 files changed, 43 insertions, 0 deletions
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))