Opened 17 years ago

Closed 17 years ago

#5020 closed (fixed)

select_related() implicit joins

Reported by: David Cramer <dcramer@…> Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Keywords: qs-rf-fixed
Cc: jesse.lovelace@…, tailofthesun@…, gav@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Add support for implicitly selecting fields to join with.

e.g. MyModel.objects.all().select_related('myforeignkey__user')

See also: http://groups.google.com/group/django-developers/browse_thread/thread/3b33bfe1e625b4ad/06b0a5f39e08d17d#06b0a5f39e08d17d

Attachments (5)

query.py.diff (5.4 KB ) - added by David Cramer <dcramer@…> 17 years ago.
models.py (2.0 KB ) - added by David Cramer <dcramer@…> 17 years ago.
unit tests
query.py.2.diff (5.5 KB ) - added by David Cramer <dcramer@…> 17 years ago.
fixed two minor bugs
query.py.3.diff (5.4 KB ) - added by David Cramer <dcramer@…> 17 years ago.
get_cached_row had a slipup
query.py.4.diff (7.3 KB ) - added by nostgard <nostgard@…> 17 years ago.
clones and uses _recurse_fields

Download all attachments as: .zip

Change History (17)

by David Cramer <dcramer@…>, 17 years ago

Attachment: query.py.diff added

comment:1 by David Cramer <dcramer@…>, 17 years ago

Has patch: set
Needs documentation: set
Needs tests: set

I've attached a patch. It needs unittests and should be tested with trunk.

by David Cramer <dcramer@…>, 17 years ago

Attachment: models.py added

unit tests

comment:2 by David Cramer <dcramer@…>, 17 years ago

Needs tests: unset

by David Cramer <dcramer@…>, 17 years ago

Attachment: query.py.2.diff added

fixed two minor bugs

by David Cramer <dcramer@…>, 17 years ago

Attachment: query.py.3.diff added

get_cached_row had a slipup

comment:3 by nostgard <nostgard@…>, 17 years ago

The patches provided didn't actually filter my related objects, as_recurse_fields was never saved when cloned and fields= wasn't supplied to the functions. I added a patch with that.

Thanks for doing this. I had rolled my own for this, but it wasn't nearly as clean.

by nostgard <nostgard@…>, 17 years ago

Attachment: query.py.4.diff added

clones and uses _recurse_fields

comment:4 by Chris Beaven, 17 years ago

Owner: changed from Adrian Holovaty to Malcolm Tredinnick
Triage Stage: UnreviewedDesign decision needed

Haven't heard from Malcolm about it yet.

comment:5 by anonymous, 17 years ago

Cc: jesse.lovelace@… added

comment:6 by Malcolm Tredinnick, 17 years ago

Keywords: qs-rf added

comment:7 by anonymous, 17 years ago

Cc: tailofthesun@… added

comment:8 by George Vilches, 17 years ago

Cc: gav@… added

comment:9 by Malcolm Tredinnick, 17 years ago

(In [6899]) queryset-refactor: Allow specifying of specific relations to follow in
select_related(). Refs #5020.

comment:10 by Malcolm Tredinnick, 17 years ago

Keywords: qs-rf-fixed added; qs-rf removed

comment:11 by Chris Beaven, 17 years ago

Triage Stage: Design decision neededAccepted

Promoting to accepted: if it's fixed in the queryset refactor then it has obviously an accepted issue.

comment:12 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: newclosed

(In [7477]) Merged the queryset-refactor branch into trunk.

This is a big internal change, but mostly backwards compatible with existing
code. Also adds a couple of new features.

Fixed #245, #1050, #1656, #1801, #2076, #2091, #2150, #2253, #2306, #2400, #2430, #2482, #2496, #2676, #2737, #2874, #2902, #2939, #3037, #3141, #3288, #3440, #3592, #3739, #4088, #4260, #4289, #4306, #4358, #4464, #4510, #4858, #5012, #5020, #5261, #5295, #5321, #5324, #5325, #5555, #5707, #5796, #5817, #5987, #6018, #6074, #6088, #6154, #6177, #6180, #6203, #6658

Note: See TracTickets for help on using tickets.
Back to Top