summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2026-02-19 14:44:01 -0500
committerJacob Walls <jacobtylerwalls@gmail.com>2026-02-20 09:12:49 -0500
commitf9b820f8ac50aad025949087e660a551691832e4 (patch)
tree1ecbec2d2ea9974c37d4ed97cd3262436074d305
parentdeac58ed822c6cd819e916e6c3d1736c7adfa31e (diff)
[6.0.x] Fixed #36934, Refs #35972 -- Coped with params in a tuple in BuiltinLookup.as_sql().
For custom lookups subclassing BuiltinLookup and following the advice in the release notes to return params in a tuple, this change will obviate the need to audit as_sql() in addition to process_lhs() to be "resilient against either tuples or lists" as described in the release note. Regression in 8914f4703cf03e2a01683c4ba00f5ae7d3fa449d.
-rw-r--r--django/db/models/lookups.py4
-rw-r--r--docs/releases/6.0.3.txt4
-rw-r--r--docs/releases/6.0.txt2
3 files changed, 8 insertions, 2 deletions
diff --git a/django/db/models/lookups.py b/django/db/models/lookups.py
index 65128732fd..3181bc122c 100644
--- a/django/db/models/lookups.py
+++ b/django/db/models/lookups.py
@@ -237,7 +237,7 @@ class BuiltinLookup(Lookup):
def as_sql(self, compiler, connection):
lhs_sql, params = self.process_lhs(compiler, connection)
rhs_sql, rhs_params = self.process_rhs(compiler, connection)
- params.extend(rhs_params)
+ params = (*params, *rhs_params)
rhs_sql = self.get_rhs_op(connection, rhs_sql)
return "%s %s" % (lhs_sql, rhs_sql), params
@@ -725,7 +725,7 @@ class YearLookup(Lookup):
rhs_sql, _ = self.process_rhs(compiler, connection)
rhs_sql = self.get_direct_rhs_sql(connection, rhs_sql)
start, finish = self.year_lookup_bounds(connection, self.rhs)
- params.extend(self.get_bound_params(start, finish))
+ params = (*params, *self.get_bound_params(start, finish))
return "%s %s" % (lhs_sql, rhs_sql), params
return super().as_sql(compiler, connection)
diff --git a/docs/releases/6.0.3.txt b/docs/releases/6.0.3.txt
index ddd853cd49..1dff197d06 100644
--- a/docs/releases/6.0.3.txt
+++ b/docs/releases/6.0.3.txt
@@ -11,3 +11,7 @@ Bugfixes
* Fixed :exc:`NameError` when inspecting functions making use of deferred
annotations in Python 3.14 (:ticket:`36903`).
+
+* Fixed :exc:`AttributeError` when subclassing builtin lookups and neglecting
+ to :ref:`override<tuple-for-params>` ``as_sql()`` to accept any sequence
+ (:ticket:`36934`).
diff --git a/docs/releases/6.0.txt b/docs/releases/6.0.txt
index bfad64e485..1697a095c9 100644
--- a/docs/releases/6.0.txt
+++ b/docs/releases/6.0.txt
@@ -454,6 +454,8 @@ If you haven't dealt with this warning by now, add
settings, or ``default_auto_field = 'django.db.models.AutoField'`` to an app's
``AppConfig``, as needed.
+.. _tuple-for-params:
+
Custom ORM expressions should return params as a tuple
------------------------------------------------------