From a2cce1bf43552e699f2babe7e4750354f2d580fe Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 12 Oct 2013 20:21:18 -0400 Subject: Parenthesis will be applied to a compound SQL expression as rendered in the column list of a CREATE INDEX statement. [ticket:2742] --- test/dialect/postgresql/test_compiler.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (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 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): -- cgit v1.2.1