Leaklens

django__django-13028

Queryset raises NotSupportedError when RHS has filterable=False attribute.

Verdict: the issue text repeats lines of the gold patch (Tier C).

We should be able to fix this by checking if rhs is an expression: diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index ce18098fd2..ad981377a0 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -1124,7 +1124,7 @@ class Query(BaseExpression): def check_filterable(self, expression): """Raise an error if expression cannot be used in a WHERE clause.""" - if not getattr(expression, 'filterable', True): + if hasattr(expression, 'resolve_expression') and not getattr(expression, 'filterable', True): raise NotSupportedError(

2 of 2 added patch lines appear in the issue or discussion.

All SWE-bench Verified tasks · more django/django tasks · How the check works