summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-10-12 20:21:18 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-10-12 20:21:18 -0400
commita2cce1bf43552e699f2babe7e4750354f2d580fe (patch)
tree6a51ca1dba5b26cd69770f777ba89c429cafb177 /test/dialect/postgresql/test_compiler.py
parent9bc9d5c1068be878118202259add3c2e1bcec0cb (diff)
downloadsqlalchemy-a2cce1bf43552e699f2babe7e4750354f2d580fe.tar.gz
Parenthesis will be applied to a compound SQL expression as
rendered in the column list of a CREATE INDEX statement. [ticket:2742]
Diffstat (limited to 'test/dialect/postgresql/test_compiler.py')
-rw-r--r--test/dialect/postgresql/test_compiler.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py
index 858f3e763..76fd9d907 100644
--- a/test/dialect/postgresql/test_compiler.py
+++ b/test/dialect/postgresql/test_compiler.py
@@ -173,6 +173,17 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
'USING hash (data)',
dialect=postgresql.dialect())
+
+ def test_create_index_expr_gets_parens(self):
+ m = MetaData()
+ tbl = Table('testtbl', m, Column('x', Integer), Column('y', Integer))
+
+ idx1 = Index('test_idx1', 5 / (tbl.c.x + tbl.c.y))
+ self.assert_compile(
+ schema.CreateIndex(idx1),
+ "CREATE INDEX test_idx1 ON testtbl ((5 / (x + y)))"
+ )
+
def test_create_index_literals(self):
m = MetaData()
tbl = Table('testtbl', m, Column('data', Integer))
@@ -180,7 +191,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
idx1 = Index('test_idx1', tbl.c.data + 5)
self.assert_compile(
schema.CreateIndex(idx1),
- "CREATE INDEX test_idx1 ON testtbl (data + 5)"
+ "CREATE INDEX test_idx1 ON testtbl ((data + 5))"
)
def test_exclude_constraint_min(self):