diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-12-05 14:56:26 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-12-05 14:56:26 -0500 |
commit | f1e54a69fb9b07a73bd8488110b1ceace168a50a (patch) | |
tree | 9ffef9bc95b2015877f5dcfa63fb6574a87ca15e /lib/sqlalchemy/sql/operators.py | |
parent | 77763969ff06b12edcbaedab62890afa27e105b4 (diff) | |
parent | 926b0d7fa860abee8b34236148fa34a6666700a9 (diff) | |
download | sqlalchemy-f1e54a69fb9b07a73bd8488110b1ceace168a50a.tar.gz |
- merge default tip
Diffstat (limited to 'lib/sqlalchemy/sql/operators.py')
-rw-r--r-- | lib/sqlalchemy/sql/operators.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/operators.py b/lib/sqlalchemy/sql/operators.py index 67830f7cf..0577e6668 100644 --- a/lib/sqlalchemy/sql/operators.py +++ b/lib/sqlalchemy/sql/operators.py @@ -83,10 +83,14 @@ def desc_op(a): def asc_op(a): return a.asc() -_commutative = set([eq, ne, add, mul, and_]) +_commutative = set([eq, ne, add, mul]) + def is_commutative(op): return op in _commutative +_associative = _commutative.union([concat_op, and_, or_]) + + _smallest = symbol('_smallest') _largest = symbol('_largest') @@ -131,5 +135,8 @@ _PRECEDENCE = { } def is_precedent(operator, against): - return (_PRECEDENCE.get(operator, _PRECEDENCE[_smallest]) <= + if operator is against and operator in _associative: + return False + else: + return (_PRECEDENCE.get(operator, _PRECEDENCE[_smallest]) <= _PRECEDENCE.get(against, _PRECEDENCE[_largest])) |