#33647: bulk_update silently truncating values for size limited fields
-------------------------------------+-------------------------------------
Reporter: jerch | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by jerch):
Replying to [comment:1 Simon Charette]:
> ... this is due to `requires_casted_case_in_updates=True` on the
Postgres backend does a silent `::varchar(2)` cast on the `CASE`
statement.
Then only postgres is affected here? (from the code it seems that other
backends dont set this flag...)
For postgres the next question would be, if other data types with
contraints are affected as well (basically any type, that allows narrowing
by `type(???)` notation), or if this is a varchar only edge case. From
https://www.postgresql.org/docs/current/datatype.html possible candidates
for `type != type(???)` behavior are:
- bit
- bit varying
- character
- character varying
- interval
- numeric
- time
- timestamp
Imho django uses most of these for some field type (beside bit/bit
varying?)
In general the broader "super" type with no constraints can be derived in
postgres like this:
{{{
#!div style="font-size: 80%"
Code highlighting:
{{{#!sql
postgres=# select 'varchar(5)'::regtype;
regtype
-------------------
character varying
(1 row)
}}}
}}}
Maybe it is enough to apply the super type to the cast in that line
https://github.com/django/django/blob/a1e4e86f923dc8387b0a9c3025bdd5d096a6ebb8/django/db/models/query.py#L765?
--
Ticket URL: <https://code.djangoproject.com/ticket/33647#comment:2>
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/0107018031c7d9e6-4fa93cbf-7d0a-4f5c-8e70-70adb9cf4b5f-000000%40eu-central-1.amazonses.com.