diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-07-22 16:36:29 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-07-22 16:36:29 -0400 |
commit | faa9b2c8da63aa116579fc6c43a30ce479b92ac2 (patch) | |
tree | 30a75f94f18a9f51197658e5b0a8d5ae1b09753d /lib/sqlalchemy/sql/compiler.py | |
parent | 2bee05098e09dcdf09f7c8ff1c7efeba0c2fc9f2 (diff) | |
download | sqlalchemy-faa9b2c8da63aa116579fc6c43a30ce479b92ac2.tar.gz |
- [feature] Revised the rules used to determine
the operator precedence for the user-defined
operator, i.e. that granted using the ``op()``
method. Previously, the smallest precedence
was applied in all cases, now the default
precedence is zero, lower than all operators
except "comma" (such as, used in the argument
list of a ``func`` call) and "AS", and is
also customizable via the "precedence" argument
on the ``op()`` method. [ticket:2537]
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 3304cff43..2588de6b4 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -663,15 +663,16 @@ class SQLCompiler(engine.Compiled): (' ESCAPE ' + self.render_literal_value(escape, None)) or '') + def visit_custom_op(self, element, dispatch_operator, dispatch_fn, **kw): + return dispatch_fn(" " + dispatch_operator.opstring + " ") + def _operator_dispatch(self, operator, element, fn, **kw): - if util.callable(operator): - disp = getattr(self, "visit_%s" % operator.__name__, None) - if disp: - return disp(element, **kw) - else: - return fn(OPERATORS[operator]) + disp = getattr(self, "visit_%s" % operator.__name__, None) + if disp: + kw.update(dispatch_operator=operator, dispatch_fn=fn) + return disp(element, **kw) else: - return fn(" " + operator + " ") + return fn(OPERATORS[operator]) def visit_bindparam(self, bindparam, within_columns_clause=False, literal_binds=False, **kwargs): |