diff options
author | Jason Kirtland <jek@discorporate.us> | 2008-07-15 21:43:02 +0000 |
---|---|---|
committer | Jason Kirtland <jek@discorporate.us> | 2008-07-15 21:43:02 +0000 |
commit | 38f982c022e710a7cd91021191fe07cfcc53e1fe (patch) | |
tree | 0a3e00827e3327d7f770f56388c48a7d51912505 /lib/sqlalchemy/sql/operators.py | |
parent | 3da6297d78a699087e538bb8fc5a92039ff21f98 (diff) | |
download | sqlalchemy-38f982c022e710a7cd91021191fe07cfcc53e1fe.tar.gz |
- Moved to 2.4+ import syntax (w/ some experimental merge-friendly formatting)
Diffstat (limited to 'lib/sqlalchemy/sql/operators.py')
-rw-r--r-- | lib/sqlalchemy/sql/operators.py | 69 |
1 files changed, 36 insertions, 33 deletions
diff --git a/lib/sqlalchemy/sql/operators.py b/lib/sqlalchemy/sql/operators.py index cc96f2e64..d28a6e0f5 100644 --- a/lib/sqlalchemy/sql/operators.py +++ b/lib/sqlalchemy/sql/operators.py @@ -3,10 +3,12 @@ """Defines operators used in SQL expressions.""" -from operator import and_, or_, inv, add, mul, sub, div, mod, truediv, \ - lt, le, ne, gt, ge, eq +from operator import ( + and_, or_, inv, add, mul, sub, div, mod, truediv, lt, le, ne, gt, ge, eq + ) from sqlalchemy.util import symbol + def from_(): raise NotImplementedError() @@ -84,40 +86,41 @@ _smallest = symbol('_smallest') _largest = symbol('_largest') _PRECEDENCE = { - from_:15, - mul:7, - div:7, - mod:7, - add:6, - sub:6, - 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, - eq:5, - ne:5, - gt:5, - lt:5, - ge:5, - le:5, - between_op:5, - distinct_op:5, - inv:5, - and_:3, - or_:2, - comma_op:-1, + from_: 15, + mul: 7, + div: 7, + mod: 7, + add: 6, + sub: 6, + 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, + eq: 5, + ne: 5, + gt: 5, + lt: 5, + ge: 5, + le: 5, + between_op: 5, + distinct_op: 5, + inv: 5, + and_: 3, + or_: 2, + comma_op: -1, collate: -2, - as_:-1, - exists:0, + as_: -1, + exists: 0, _smallest: -1000, _largest: 1000 } def is_precedent(operator, against): - return _PRECEDENCE.get(operator, _PRECEDENCE[_smallest]) <= _PRECEDENCE.get(against, _PRECEDENCE[_largest]) + return (_PRECEDENCE.get(operator, _PRECEDENCE[_smallest]) <= + _PRECEDENCE.get(against, _PRECEDENCE[_largest])) |