synchronize_session='evaluate' does not work when filtering by relation

Issue #3700 resolved
Gabor Gombas created an issue

Hi,

It seems Query.delete(synchronize_session='evaluate') does not work if there is a filter condition which references a relation instead of a column. Tested with SQLAlchemy 1.0.11.

Gabor

Comments (5)

  1. Mike Bayer repo owner

    ok this patch will resolve:

    diff --git a/lib/sqlalchemy/orm/evaluator.py b/lib/sqlalchemy/orm/evaluator.py
    index 534e7fa..6b5da12 100644
    --- a/lib/sqlalchemy/orm/evaluator.py
    +++ b/lib/sqlalchemy/orm/evaluator.py
    @@ -130,5 +130,8 @@ class EvaluatorCompiler(object):
                 (type(clause).__name__, clause.operator))
    
         def visit_bindparam(self, clause):
    -        val = clause.value
    +        if clause.callable:
    +            val = clause.callable()
    +        else:
    +            val = clause.value
             return lambda obj: val
    
  2. Mike Bayer repo owner

    Accommodate "callable" bound param in evaluator

    Fixed bug in "evaluate" strategy of :meth:.Query.update and :meth:.Query.delete which would fail to accommodate a bound parameter with a "callable" value, as which occurs when filtering by a many-to-one equality expression along a relationship.

    Change-Id: I47758d3f5d8b9ea1a07e23166780d5f3c32b17f1 Fixes: #3700 (cherry picked from commit a51ab916622dd016ce51d6be0969112817cc42ad)

    → <<cset 0470abadd237>>

  3. Mike Bayer repo owner

    Accommodate "callable" bound param in evaluator

    Fixed bug in "evaluate" strategy of :meth:.Query.update and :meth:.Query.delete which would fail to accommodate a bound parameter with a "callable" value, as which occurs when filtering by a many-to-one equality expression along a relationship.

    Change-Id: I47758d3f5d8b9ea1a07e23166780d5f3c32b17f1 Fixes: #3700

    → <<cset a51ab916622d>>

  4. Log in to comment