[Django] #28834: Fields cache should attempt to follow ancestor links on lookup failures

6 views
Skip to first unread message

Django

unread,
Nov 23, 2017, 2:12:48 AM11/23/17
to django-...@googlegroups.com
#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.

Django

unread,
Nov 23, 2017, 2:17:38 AM11/23/17
to django-...@googlegroups.com
#28834: Fields cache should attempt to follow ancestor links on lookup failures
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
Type: | Charette
Cleanup/optimization | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

[https://github.com/django/django/pull/9380 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/28834#comment:1>

Django

unread,
Nov 27, 2017, 2:07:57 PM11/27/17
to django-...@googlegroups.com
#28834: Fields cache should attempt to follow ancestor links on lookup failures
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
Type: | Charette
Cleanup/optimization | Status: assigned
Component: Database layer | Version: master
(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 Tim Graham):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/28834#comment:2>

Django

unread,
Nov 28, 2017, 10:06:18 AM11/28/17
to django-...@googlegroups.com
#28834: Fields cache should attempt to follow ancestor links on lookup failures
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
Type: | Charette
Cleanup/optimization | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/28834#comment:3>

Django

unread,
Nov 29, 2017, 1:30:04 AM11/29/17
to django-...@googlegroups.com
#28834: Fields cache should attempt to follow ancestor links on lookup failures
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
Type: | Charette
Cleanup/optimization | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette <charette.s@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"78c5e7b90eee10067d39a8ba6588e6b53ba00d82" 78c5e7b]:
{{{
#!CommitTicketReference repository=""
revision="78c5e7b90eee10067d39a8ba6588e6b53ba00d82"
Fixed #28834 -- Followed ancestor links on field cache lookup failure.

Thanks Tim for the review.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28834#comment:4>

Django

unread,
May 14, 2018, 9:40:52 PM5/14/18
to django-...@googlegroups.com
#28834: Fields cache should attempt to follow ancestor links on lookup failures
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
Type: | Charette
Cleanup/optimization | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"265506bbc347a6b3fcc6c66ab1a2417b3b7ea57a" 265506bb]:
{{{
#!CommitTicketReference repository=""
revision="265506bbc347a6b3fcc6c66ab1a2417b3b7ea57a"
Refs #28834 -- Moved ancestor field cached value fallback to related
fields descriptor.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28834#comment:5>

Reply all
Reply to author
Forward
0 new messages