.. changelog::
:version: 1.0.13
+ .. change::
+ :tags: bug, orm
+ :tickets: 3700
+
+ 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::
:tags: bug, postgresql
:tickets: 3715
(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
"""Evaluating SQL expressions on ORM objects"""
-from sqlalchemy import String, Integer
+from sqlalchemy import String, Integer, bindparam
from sqlalchemy.testing.schema import Table
from sqlalchemy.testing.schema import Column
from sqlalchemy.testing import fixtures
(User(id=None), None),
])
+ def test_compare_to_callable_bind(self):
+ User = self.classes.User
+
+ eval_eq(
+ User.name == bindparam('x', callable_=lambda: 'foo'),
+ testcases=[
+ (User(name='foo'), True),
+ (User(name='bar'), False),
+ (User(name=None), None),
+ ]
+ )
+
def test_compare_to_none(self):
User = self.classes.User