#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
-------------------------------------+-------------------------------------
Comment (by Simon Charette):

 > My rationale was that the usual Django deferred lookup works when a str
 is used, but it only fails when prefetch_related_objects is used, so this
 looked like the more consistent behaviour.

 I understand where that could be perceived as inconsistent but I would
 argue that it's undefined behaviour in both cases. It only happens to work
 in the lazy loading case because it incurs a query that defers the lookup
 to the backend.

 > I don't think other types such as DecimalField etc are commonly used as
 primary keys.

 Fair point, it remains unnecessary while arguably faster validation for
 `AutoField, `UUIDField`, and others though.

 > In my real world example the model instance is instantiated from a JSON
 object in a generic way, and foreign keys are set using the attnames where
 it is not possible to know the actual data type.

 If you are turning a ''raw'' JSON object to a model instance I think that
 you should be expected to call `clean_fields` at the very least.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35434#comment:7>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018f49ae520c-f98c53bf-6096-4414-b673-78b1bfffca5e-000000%40eu-central-1.amazonses.com.

Reply via email to