Code

Opened 6 years ago

Closed 6 years ago

#8119 closed (duplicate)

Accessing single related (parent) objects should not bypass manager

Reported by: isagalaev Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

This is a spun-of from http://code.djangoproject.com/ticket/7666#comment:7 with the relevant discussion here: http://groups.google.com/group/django-developers/browse_frm/thread/a2326c32f8860fb0/

The solution is to have a separate queryset factory on a manager get_full_query_set that can be overridden but is required to return all records. Old get_query_set normally just calls get_full_query_set and can be overridden in a usual way. This part is backwards compatible. Also managers acquire a new method get_full which works like get but explicitly calls get_full_query_set. This method is used to access single related (parent) objects. This will require users who was overriding get to override get_full instead if they wish to ensure that default filtering doesn't get in the way. This is as backwards incompatible as was after #7666 that has broken overriding of get but provides a new API to overcome this.

Attachments (1)

8119.diff (2.5 KB) - added by isagalaev 6 years ago.
Patch

Download all attachments as: .zip

Change History (2)

Changed 6 years ago by isagalaev

Patch

comment:1 Changed 6 years ago by jbronn

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Ivan, this is a duplicate of #7904. So I've added your patch, comments, and title to that ticket instead so we may centralize our discussion of this issue.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.