#27595: Database converters are not run for related fields referencing related
fields
-------------------------------------+-------------------------------------
Reporter: oyooyo | Owner: Wayne
| Merry
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(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 Simon Charette):
Alright so the underlying issue is the fact the `prototype` foreign key
point to `Prototype_Model`'s primary key which is a `OneToOneField`.
Somehow the related field chain is not followed along to determine the
non-related internal type and prevents the database converters from
correctly being chosen.
https://github.com/django/django/blob/084573c7156530047bec2c19e732423fa9d0ec13/django/db/backends/sqlite3/operations.py#L210-L220
It looks like most of the places that relies on `get_internal_type` could
be affected by that. Here's one example that works for one level
relationship chains but not for multiple ones
https://github.com/django/django/blob/084573c7156530047bec2c19e732423fa9d0ec13/django/db/backends/oracle/operations.py#L557
I think the solution here is to add a new `get_target_internal_type`
method on `ForeignKey` and along these lines
{{{#!python
def get_target_internal_type(self):
if isinstance(self.target, ForeignKey):
return self.target.get_target_internal_type()
return self.target.get_internal_type()
}}}
And audit the `get_internal_type()` usages to determine if they need to be
adjusted to call this method or not.
--
Ticket URL: <https://code.djangoproject.com/ticket/27595#comment:6>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.b0654c78a8d83a4f87ae8fed9007faf3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.