* type: Uncategorized => Bug
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
Comment:
Thanks for the report! It is a long standing bug introduced in
88fc9e2826044110b7b22577a227f122fe9c1fb5 that began manifesting in Django
4.1. The following patch fixes it for me:
{{{#!diff
diff --git a/django/contrib/postgres/fields/array.py
b/django/contrib/postgres/fields/array.py
index c247387eb7..eaff032465 100644
--- a/django/contrib/postgres/fields/array.py
+++ b/django/contrib/postgres/fields/array.py
@@ -297,7 +297,7 @@ class ArrayLenTransform(Transform):
return (
"CASE WHEN %(lhs)s IS NULL THEN NULL ELSE "
"coalesce(array_length(%(lhs)s, 1), 0) END"
- ) % {"lhs": lhs}, params
+ ) % {"lhs": lhs}, params * 2
@ArrayField.register_lookup
}}}
We two `lhs`, so we need to pass `params` for both.
Would you like to prepare a patch? (a regression test is required, I'd add
it to the `postgres_tests.test_constraints.SchemaTests`.)
--
Ticket URL: <https://code.djangoproject.com/ticket/34205#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.