Opened 10 months ago

Closed 10 months ago

Last modified 10 months ago

#35162 closed Bug (fixed)

Adding a BinaryField, TextField, JSONField, or GeometryField with a db_default crashes on MySQL

Reported by: Simon Charette Owned by: Simon Charette
Component: Database layer (models, ORM) Version: 5.0
Severity: Release blocker Keywords: mysql db_default text json blob geometry
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

Change History (4)

comment:1 by Mariusz Felisiak, 10 months ago

Has patch: set
Triage Stage: UnreviewedAccepted

comment:2 by Mariusz Felisiak, 10 months ago

Triage Stage: AcceptedReady for checkin

comment:3 by Mariusz Felisiak <felisiak.mariusz@…>, 10 months ago

Resolution: fixed
Status: assignedclosed

In dfc77637:

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.

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 10 months ago

In 3e7a30fb:

[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

Note: See TracTickets for help on using tickets.
Back to Top