#28834: Fields cache should attempt to follow ancestor links on lookup failures
-------------------------------------+-------------------------------------
Reporter: Simon | Owner: Simon Charette
Charette |
Type: | Status: assigned
Cleanup/optimization |
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Given the following models
{{{#!python
class Chef(model.Model):
pass
class Restaurant(models.Model):
chef = models.ForeignKey(Chef)
class ItalianRestaurant(Restaurant):
pass
}}}
Then given `restaurant.chef` is cached accessing
`restaurant.italianrestaurant.chef` shouldn't incur an additional query.
e.g.
{{{#!python
chef = Chef.objects.create()
italian_restaurant = ItalianRestaurant.objects.create(chef=chef)
# A single query with two joins
restaurant = Restaurant.objects.select_related('chef',
'italianrestaurant').get(pk=italian_restaurant.pk)
assert restaurant.chef == chef # Currently no queries.
assert restaurant.italian_restaurant == italian_restaurant # Currently no
queries.
assert restaurant.italian_restaurant.chef is restaurant.chef # Currently
fails and performs a query.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28834>
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/052.0208d022e36b464c84389cbecd8d6456%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.