[Django] #35162: Adding a BinaryField, TextField, JSONField, or GeometryField with a db_default crashes on MySQL

7 views
Skip to first unread message

Django

unread,
Feb 3, 2024, 10:54:25 AMFeb 3
to django-...@googlegroups.com
#35162: Adding a BinaryField, TextField, JSONField, or GeometryField with a
db_default crashes on MySQL
-------------------------------------+-------------------------------------
Reporter: Simon | Owner: Simon Charette
Charette |
Type: Bug | Status: assigned
Component: Database | Version: 5.0
layer (models, ORM) |
Severity: Release | Keywords: mysql db_default
blocker | text json blob geometry
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
MySQL do not support literal value `DEFAULT` for these fields and requires
them to be wrapped in parenthesis so they are considered expressions.

This is already something we must handle when using `DEFAULT` to add
fields with a `default` so all the backend specific logic lives in in
`_column_default_sql` so it's only a matter of using it in
`db_default_sql`.
--
Ticket URL: <https://code.djangoproject.com/ticket/35162>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 3, 2024, 1:11:26 PMFeb 3
to django-...@googlegroups.com
#35162: Adding a BinaryField, TextField, JSONField, or GeometryField with a
db_default crashes on MySQL
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon

| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: mysql db_default | Triage Stage: Accepted
text json blob geometry |
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
* stage: Unreviewed => Accepted

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

Django

unread,
Feb 3, 2024, 1:11:40 PMFeb 3
to django-...@googlegroups.com
#35162: Adding a BinaryField, TextField, JSONField, or GeometryField with a
db_default crashes on MySQL
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: mysql db_default | Triage Stage: Ready for
text json blob geometry | checkin

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

* stage: Accepted => Ready for checkin

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

Django

unread,
Feb 4, 2024, 3:24:27 AMFeb 4
to django-...@googlegroups.com
#35162: Adding a BinaryField, TextField, JSONField, or GeometryField with a
db_default crashes on MySQL
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
| Charette
Type: Bug | Status: closed

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

Keywords: mysql db_default | Triage Stage: Ready for
text json blob geometry | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

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

Comment:

In [changeset:"dfc77637ea5c1aa81caa72b1cf900e6931d61b54" dfc77637]:
{{{#!CommitTicketReference repository=""
revision="dfc77637ea5c1aa81caa72b1cf900e6931d61b54"
Fixed #35162 -- Fixed crash when adding fields with db_default on MySQL.

MySQL doesn't allow literal DEFAULT values to be used for BLOB, TEXT,
GEOMETRY or JSON columns and requires expression to be used instead.

Regression in 7414704e88d73dafbcfbb85f9bc54cb6111439d3.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35162#comment:3>

Django

unread,
Feb 4, 2024, 3:24:57 AMFeb 4
to django-...@googlegroups.com
#35162: Adding a BinaryField, TextField, JSONField, or GeometryField with a
db_default crashes on MySQL
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
| Charette
Type: Bug | Status: closed
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: mysql db_default | Triage Stage: Ready for
text json blob geometry | checkin
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:"3e7a30fb3a5ea38d06bbedd53e2130bf192425c7" 3e7a30fb]:
{{{#!CommitTicketReference repository=""
revision="3e7a30fb3a5ea38d06bbedd53e2130bf192425c7"
[5.0.x] Fixed #35162 -- Fixed crash when adding fields with db_default on
MySQL.

MySQL doesn't allow literal DEFAULT values to be used for BLOB, TEXT,
GEOMETRY or JSON columns and requires expression to be used instead.

Regression in 7414704e88d73dafbcfbb85f9bc54cb6111439d3.

Backport of dfc77637ea5c1aa81caa72b1cf900e6931d61b54 from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35162#comment:4>

Reply all
Reply to author
Forward
0 new messages