#34944: Missing or misinferred attributes in output fields of generated fields
-------------------------------------+-------------------------------------
Reporter: Paolo Melchiorre | Owner: Om Dahale
Type: Bug | Status: assigned
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: field, database, | Triage Stage: Accepted
generated, output_field |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):
Resolving the `output_field` of combined expressions is a complex task
that the ORM only has limited support for #26355, #31506, #33397, this is
not a problem specific to `GenerateField`.
It is particularly tricky in the case of `varchar(x) + varchar(y)` as some
backends restrict the allowed length of `varchar` (e.g. MySQL as 255) and
using a `TextField` might come with backend specific limitations.
Our stance so far has been to make a best effort guess and
[https://docs.djangoproject.com/en/4.2/ref/models/expressions/#output-
field refuse the temptation to guess otherwise].
I suggest that we take the same approach here and expect the user to
specify an explicit `output_field`.
For the second part of the problem, `CharField(None)`, I think that the
addition of a check is in order. Adding a
`GeneratedField._check_output_field` that simply delegates to
`self.output_field.check(**kwargs)` seems like the way to go to catch all
misuse of `output_field`.
--
Ticket URL: <https://code.djangoproject.com/ticket/34944#comment:14>
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 on the web visit
https://groups.google.com/d/msgid/django-updates/0107018bacb1124f-1e69d86b-8d82-45c4-bbae-195fff700643-000000%40eu-central-1.amazonses.com.