#35434: prefetch_related_objects fails to cache UUID FKs when the string
representation of a UUID is used
-------------------------------------+-------------------------------------
Reporter: Selcuk Ayguney | Owner: Selcuk
| Ayguney
Type: Bug | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):
* cc: Simon Charette (added)
Comment:
Have we performed any form of benchmarks to assess the impact of calling
`to_python` for each sides of the prefetching ''bridge''?
`Field.to_python` can perform non-trivial validation and instance checks
that quickly add up when dealing with large collection of objects.
Given `prefetch_related_object` is normally called from a
`prefetch_related` queryset where both sides are already guaranteed to be
of the right type and serializers/forms are meant to be turn
representations of objects to the expected field types at input boundaries
it seems like this change could do more harm than good both from a
performance and areas of concerns violation perspective.
My question to you would be why you are assigning the unexpected type to
field in the first place (the `pet_id=str(pet.id)`)? Plenty of things
subtly break if you assign the string representation of a `DateField`,
`DecimalField`, `FloatField`, etc to a model instance field instead of the
proper type so I'm not sure how this particular case is special. If you
have to assign such properties I believe you should call `.full_clean()` /
`clean_fields()` on the model instance and be ready to deal with any
associated `ValidationError`.
I'm more of the opinion that we should wont-fix this issue than proceed
here.
--
Ticket URL: <https://code.djangoproject.com/ticket/35434#comment:5>
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/0107018f499d80c7-8e25c675-3400-4c02-abe6-0f7198d44b1c-000000%40eu-central-1.amazonses.com.