[Django] #37403: JSONIn crashes at database level when preparing a models.Value(None, models.CharField()) on SQLite

6 views
Skip to first unread message

Django

unread,
Oct 6, 2026, 11:52:41 AM (5 days ago) Oct 6
to django-...@googlegroups.com
#37403: JSONIn crashes at database level when preparing a models.Value(None,
models.CharField()) on SQLite
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Type: Bug
Status: new | Component: Database
| layer (models, ORM)
Version: 6.1 | Severity: Release
| blocker
Keywords: json, output_field, | Triage Stage:
null | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
`Value(None, output_field=CharField())` represents SQL `NULL` and compiles
without bound parameters. This query worked on 6.0 on SQLite:

{{{#!py
from django.db import models

class Person(models.Model):
metadata = models.JSONField()

def run():
qs = Person.objects.filter(metadata__in=[models.Value(None,
models.CharField())])
print(qs)
}}}
{{{#!sql
SELECT "app_person"."id",
"app_person"."metadata"
FROM "app_person"
WHERE "app_person"."metadata" IN (NULL)
LIMIT 21
}}}

But after 9b8e4c6d7d47f7b2e96817ba334e9fd53c10a0df (6.1), it crashes on
SQLite with:
{{{#!py
File "/Users/jwalls/django/django/db/models/lookups.py", line 349, in
<genexpr>
self.resolve_expression_parameter(compiler, connection, sql, param)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jwalls/django/django/db/models/fields/json.py", line 444,
in resolve_expression_parameter
and params[0] not in connection.ops.jsonfield_datatype_values
~~~~~~^^^
IndexError: list index out of range
}}}
And differently on 6.1.2 after #37377, at the database level:
{{{#!py
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The
current statement uses 3, and there are 4 supplied.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/37403>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 6, 2026, 12:03:27 PM (5 days ago) Oct 6
to django-...@googlegroups.com
#37403: JSONIn crashes at database level when preparing a models.Value(None,
models.CharField()) on SQLite
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Clifford
| Gama
Type: Bug | Status: assigned
Component: Database layer | Version: 6.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: json, output_field, | Triage Stage:
null | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Clifford Gama):

* owner: (none) => Clifford Gama
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/37403#comment:1>

Django

unread,
Oct 6, 2026, 1:57:36 PM (5 days ago) Oct 6
to django-...@googlegroups.com
#37403: JSONIn crashes at database level when preparing a models.Value(None,
models.CharField()) on SQLite
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Clifford
| Gama
Type: Bug | Status: assigned
Component: Database layer | Version: 6.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: json, output_field, | Triage Stage: Accepted
null |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Clifford Gama):

* stage: Unreviewed => Accepted

--
Ticket URL: <https://code.djangoproject.com/ticket/37403#comment:2>

Django

unread,
Oct 6, 2026, 3:09:29 PM (5 days ago) Oct 6
to django-...@googlegroups.com
#37403: JSONIn crashes at database level when preparing a models.Value(None,
models.CharField()) on SQLite
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Clifford
| Gama
Type: Bug | Status: assigned
Component: Database layer | Version: 6.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: json, output_field, | Triage Stage: Accepted
null |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Clifford Gama):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/37403#comment:3>

Django

unread,
Oct 7, 2026, 7:06:09 PM (4 days ago) Oct 7
to django-...@googlegroups.com
#37403: JSONIn crashes at database level when preparing a models.Value(None,
models.CharField()) on SQLite
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Clifford
| Gama
Type: Bug | Status: assigned
Component: Database layer | Version: 6.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: json, output_field, | Triage Stage: Ready for
null | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/37403#comment:4>

Django

unread,
Oct 8, 2026, 8:25:49 AM (3 days ago) Oct 8
to django-...@googlegroups.com
#37403: JSONIn crashes at database level when preparing a models.Value(None,
models.CharField()) on SQLite
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Clifford
| Gama
Type: Bug | Status: closed
Component: Database layer | Version: 6.1
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: json, output_field, | Triage Stage: Ready for
null | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls <jacobtylerwalls@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"1b4d021b6525bff6439b9d3b8d5388a1a1906ecd" 1b4d021b]:
{{{#!CommitTicketReference repository=""
revision="1b4d021b6525bff6439b9d3b8d5388a1a1906ecd"
Fixed #37403 -- Fixed JSONField __in crash on SQLite with Value(None)
expressions.

Regression in 9b8e4c6d7d47f7b2e96817ba334e9fd53c10a0df.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/37403#comment:5>

Django

unread,
Oct 8, 2026, 8:26:35 AM (3 days ago) Oct 8
to django-...@googlegroups.com
#37403: JSONIn crashes at database level when preparing a models.Value(None,
models.CharField()) on SQLite
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Clifford
| Gama
Type: Bug | Status: closed
Component: Database layer | Version: 6.1
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: json, output_field, | Triage Stage: Ready for
null | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jacob Walls <jacobtylerwalls@…>):

In [changeset:"0931d3c35213b9b9562f0585629745bad89f5d9b" 0931d3c3]:
{{{#!CommitTicketReference repository=""
revision="0931d3c35213b9b9562f0585629745bad89f5d9b"
[6.1.x] Fixed #37403 -- Fixed JSONField __in crash on SQLite with
Value(None) expressions.

Regression in 9b8e4c6d7d47f7b2e96817ba334e9fd53c10a0df.

Backport of 1b4d021b6525bff6439b9d3b8d5388a1a1906ecd from main.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/37403#comment:6>
Reply all
Reply to author
Forward
0 new messages