diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-05-10 22:52:49 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-05-10 23:42:41 -0400 |
commit | b146a0c64144639bf02bafda239238e3a8f5c84d (patch) | |
tree | c9c21a160e14aa177a40f11cf436bc0b2e160659 /lib/sqlalchemy/sql/compiler.py | |
parent | 39c2815fb25052c181f98ca52a57fd7449d7090c (diff) | |
download | sqlalchemy-b146a0c64144639bf02bafda239238e3a8f5c84d.tar.gz |
set bindparam.expanding in coercion again
Adjusted the logic added as part of :ticket:`6397` in 1.4.12 so that
internal mutation of the :class:`.BindParameter` object occurs within the
clause construction phase as it did before, rather than in the compilation
phase. In the latter case, the mutation still produced side effects against
the incoming construct and additionally could potentially interfere with
other internal mutation routines.
In order to solve the issue of the correct operator being present
on the BindParameter.expand_op, we necessarily have to expand the
BinaryExpression._negate() routine to flip the operator on the
BindParameter also.
Fixes: #6460
Change-Id: I1e53a9aeee4de4fc11af51d7593431532731561b
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index dedd75f5c..734e65492 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -1904,32 +1904,14 @@ class SQLCompiler(Compiled): binary, override_operator=operators.match_op ) - def visit_in_op_binary(self, binary, operator, **kw): - return self._render_in_expr_w_bindparam(binary, operator, **kw) - def visit_not_in_op_binary(self, binary, operator, **kw): # The brackets are required in the NOT IN operation because the empty # case is handled using the form "(col NOT IN (null) OR 1 = 1)". # The presence of the OR makes the brackets required. - return "(%s)" % self._render_in_expr_w_bindparam( - binary, operator, **kw + return "(%s)" % self._generate_generic_binary( + binary, OPERATORS[operator], **kw ) - def _render_in_expr_w_bindparam(self, binary, operator, **kw): - opstring = OPERATORS[operator] - - if isinstance(binary.right, elements.BindParameter): - if not binary.right.expanding or not binary.right.expand_op: - # note that by cloning here, we rely upon the - # _cache_key_bind_match dictionary to resolve - # clones of bindparam() objects to the ones that are - # present in our cache key. - binary.right = binary.right._clone(maintain_key=True) - binary.right.expanding = True - binary.right.expand_op = operator - - return self._generate_generic_binary(binary, opstring, **kw) - def visit_empty_set_op_expr(self, type_, expand_op): if expand_op is operators.not_in_op: if len(type_) > 1: |