#36173: Usage of Concat with an explicit `output_field` results in unstable
migrations changes
-------------------------------------+-------------------------------------
Reporter: erchenstein | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Migrations | Version: 5.1
Severity: Normal | Resolution:
Keywords: migrations concat | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):
* keywords: Migrations, CheckConstraint, CONCAT => migrations concat
* owner: (none) => Simon Charette
* stage: Unreviewed => Accepted
* status: new => assigned
* summary:
POSTGRES and SQLite migrations constantly DROP and ADD check
constraint without changes to code - possibly due to use of CONCAT
function (Django 5.x)
=>
Usage of Concat with an explicit `output_field` results in unstable
migrations changes
Comment:
This is is due to the implementation of `Expression.identity` not
accounting for `__init__` overrides that have `*args` and `**kwargs`
captures. When this is the case the respective values (e.g. `extra =
{"output_field": CharField()}` in the case of `Concat`) must be
recursively unpacked to ensure `type(output_field)` is used.
From my understanding this has been a flaw of expression identity since
their inception and was missed in #30628.
You can circumvent this problem by not passing an explicit `output_field`
to your `Concat(2, Substr(F('identifier'), 1, 9))`.
--
Ticket URL: <https://code.djangoproject.com/ticket/36173#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/01070194e24755eb-2b6607f1-fae8-4875-8131-f7c37b117c2b-000000%40eu-central-1.amazonses.com.