[Django] #35024: Creating model objects crashes on fields with database converters when RETURNING is not supported.

11 views
Skip to first unread message

Django

unread,
Dec 7, 2023, 7:56:46 AM12/7/23
to django-...@googlegroups.com
#35024: Creating model objects crashes on fields with database converters when
RETURNING is not supported.
-------------------------------------+-------------------------------------
Reporter: Mariusz | Owner: Mariusz Felisiak
Felisiak |
Type: Bug | Status: assigned
Component: Database | Version: 5.0
layer (models, ORM) |
Severity: Release | Keywords:
blocker |
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Creating model objects crashes on fields with database converters when
RETURNING is not supported. For example

{{{#!python
class GeneratedBooleanFieldModel(Model):
value = IntegerField(null=True)
has_value = GeneratedField(
expression=Q(value__isnull=False),
output_field=BooleanField(),
db_persist=False,
)
}}}
crashes with:
{{{
File "/home/jenkins/workspace/pull-requests-
focal/database/spatialite/label/focal-
pr/python/python3.10/django/db/models/query.py", line 1845, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
File "/home/jenkins/workspace/pull-requests-
focal/database/spatialite/label/focal-
pr/python/python3.10/django/db/models/sql/compiler.py", line 1853, in
execute_sql
rows = list(self.apply_converters(rows, converters))
File "/home/jenkins/workspace/pull-requests-
focal/database/spatialite/label/focal-
pr/python/python3.10/django/db/models/sql/compiler.py", line 1500, in
apply_converters
value = row[pos]
IndexError: list index out of range
}}}
This is a long standing issue, however it caused a crash of
`GeneratedField` for all output fields that have backend-specific
converters when `RETURNING` clause is not supported (MySQL and SQLite <
3.35). We should exacerbate severity to a release blocker.

Regression in d9de74141e8a920940f1b91ed0a3ccb835b55729.

--
Ticket URL: <https://code.djangoproject.com/ticket/35024>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 7, 2023, 8:27:00 AM12/7/23
to django-...@googlegroups.com
#35024: Creating model objects crashes on fields with database converters when
RETURNING is not supported.
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: Mariusz

| Felisiak
Type: Bug | Status: assigned
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

[https://github.com/django/django/pull/17587 PR]

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

Django

unread,
Dec 7, 2023, 8:27:03 AM12/7/23
to django-...@googlegroups.com
#35024: Creating model objects crashes on fields with database converters when
RETURNING is not supported.
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: Mariusz
| Felisiak
Type: Bug | Status: assigned
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* has_patch: 0 => 1


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

Django

unread,
Dec 7, 2023, 8:48:15 AM12/7/23
to django-...@googlegroups.com
#35024: Creating model objects crashes on fields with database converters when
RETURNING is not supported.
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: Mariusz
| Felisiak
Type: Bug | Status: assigned
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* stage: Unreviewed => Accepted


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

Django

unread,
Dec 7, 2023, 2:50:28 PM12/7/23
to django-...@googlegroups.com
#35024: Creating model objects crashes on fields with database converters when
RETURNING is not supported.
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: Mariusz
| Felisiak
Type: Bug | Status: closed

Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

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


Comment:

In [changeset:"5b3b791e9046461901df3898be8544e14d91b931" 5b3b791]:
{{{
#!CommitTicketReference repository=""
revision="5b3b791e9046461901df3898be8544e14d91b931"
Fixed #35024 -- Fixed model instance creation crash on
GeneratedField.output_field with backend converters.

Regression in d9de74141e8a920940f1b91ed0a3ccb835b55729.

This is a long standing issue, however it caused a crash of

GeneratedFields for all output fields that have backend-specific
converters when the RETURNING clause is not supported
(MySQL and SQLite < 3.35).
That's why severity was exacerbated.
}}}

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

Django

unread,
Dec 7, 2023, 2:51:24 PM12/7/23
to django-...@googlegroups.com
#35024: Creating model objects crashes on fields with database converters when
RETURNING is not supported.
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: Mariusz
| Felisiak
Type: Bug | Status: closed
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"415a08a5283a0f76408ec23c6f6af4a0002d7651" 415a08a5]:
{{{
#!CommitTicketReference repository=""
revision="415a08a5283a0f76408ec23c6f6af4a0002d7651"
[5.0.x] Fixed #35024 -- Fixed model instance creation crash on
GeneratedField.output_field with backend converters.

Regression in d9de74141e8a920940f1b91ed0a3ccb835b55729.

This is a long standing issue, however it caused a crash of
GeneratedFields for all output fields that have backend-specific
converters when the RETURNING clause is not supported
(MySQL and SQLite < 3.35).
That's why severity was exacerbated.

Backport of 5b3b791e9046461901df3898be8544e14d91b931 from main
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/35024#comment:5>

Reply all
Reply to author
Forward
0 new messages