From: Mike Bayer Date: Sat, 22 Sep 2012 20:48:49 +0000 (-0400) Subject: - [bug] A tweak to column precedence which moves the X-Git-Tag: rel_0_8_0b1~142 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=23d300c874ef0228f5141c1435bf2dc265152a59;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - [bug] A tweak to column precedence which moves the "concat" and "match" operators to be the same as that of "is", "like", and others; this helps with parenthesization rendering when used in conjunction with "IS". [ticket:2564] --- diff --git a/CHANGES b/CHANGES index ee9f2da571..f3342f84e2 100644 --- a/CHANGES +++ b/CHANGES @@ -816,6 +816,12 @@ are also present in 0.8. operators are present as methods like all the other operators. [ticket:2544] + - [bug] A tweak to column precedence which moves the + "concat" and "match" operators to be the same as + that of "is", "like", and others; this helps with + parenthesization rendering when used in conjunction + with "IS". [ticket:2564] + - engine - [bug] Fixed bug whereby a disconnect detect + dispose that occurs diff --git a/lib/sqlalchemy/sql/operators.py b/lib/sqlalchemy/sql/operators.py index ad9fa46688..2e2ff3af15 100644 --- a/lib/sqlalchemy/sql/operators.py +++ b/lib/sqlalchemy/sql/operators.py @@ -670,31 +670,36 @@ _largest = symbol('_largest', canonical=100) _PRECEDENCE = { from_: 15, getitem: 15, - mul: 7, - truediv: 7, + mul: 8, + truediv: 8, # Py2K - div: 7, + div: 8, # end Py2K - mod: 7, - neg: 7, - add: 6, - sub: 6, + mod: 8, + neg: 8, + add: 7, + sub: 7, + concat_op: 6, match_op: 6, - ilike_op: 5, - notilike_op: 5, - like_op: 5, - notlike_op: 5, - in_op: 5, - notin_op: 5, - is_: 5, - isnot: 5, + + ilike_op: 6, + notilike_op: 6, + like_op: 6, + notlike_op: 6, + in_op: 6, + notin_op: 6, + + is_: 6, + isnot: 6, + eq: 5, ne: 5, gt: 5, lt: 5, ge: 5, le: 5, + between_op: 5, distinct_op: 5, inv: 5, diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py index 951309d195..b104f60971 100644 --- a/test/sql/test_operators.py +++ b/test/sql/test_operators.py @@ -345,6 +345,10 @@ class OperatorPrecedenceTest(fixtures.TestBase, testing.AssertsCompiledSQL): "SELECT op.field FROM op WHERE (op.field = op.field) " "BETWEEN :param_1 AND :param_2") + self.assert_compile(table.select( + table.c.field.match(table.c.field).is_(None)), + "SELECT op.field FROM op WHERE (op.field MATCH op.field) IS NULL") + class OperatorAssociativityTest(fixtures.TestBase, testing.AssertsCompiledSQL): __dialect__ = 'default'