Django

Code

Ticket #5020 (closed: fixed)

Opened 10 months ago

Last modified 3 weeks ago

select_related() implicit joins

Reported by: David Cramer <dcramer@gmail.com> Assigned to: nobody
Component: Database wrapper Version: SVN
Keywords: qs-rf-fixed Cc: jesse.lovelace@gmail.com, tailofthesun@gmail.com, gav@thataddress.com
Triage Stage: Accepted Has patch: 1
Needs documentation: 1 Needs tests: 0
Patch needs improvement: 0

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

query.py.diff (5.4 kB) - added by David Cramer <dcramer@gmail.com> on 08/01/07 11:16:00.
models.py (2.0 kB) - added by David Cramer <dcramer@gmail.com> on 08/01/07 13:44:45.
unit tests
query.py.2.diff (5.5 kB) - added by David Cramer <dcramer@gmail.com> on 08/01/07 19:14:10.
fixed two minor bugs
query.py.3.diff (5.4 kB) - added by David Cramer <dcramer@gmail.com> on 08/02/07 15:51:37.
get_cached_row had a slipup
query.py.4.diff (7.3 kB) - added by nostgard <nostgard@yahoo.com> on 08/11/07 00:25:07.
clones and uses _recurse_fields

Change History

08/01/07 11:16:00 changed by David Cramer <dcramer@gmail.com>

  • attachment query.py.diff added.

08/01/07 11:16:35 changed by David Cramer <dcramer@gmail.com>

  • needs_better_patch changed.
  • has_patch set to 1.
  • needs_tests set to 1.
  • needs_docs set to 1.

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

08/01/07 13:44:45 changed by David Cramer <dcramer@gmail.com>

  • attachment models.py added.

unit tests

08/01/07 13:44:56 changed by David Cramer <dcramer@gmail.com>

  • needs_tests deleted.

08/01/07 19:14:10 changed by David Cramer <dcramer@gmail.com>

  • attachment query.py.2.diff added.

fixed two minor bugs

08/02/07 15:51:37 changed by David Cramer <dcramer@gmail.com>

  • attachment query.py.3.diff added.

get_cached_row had a slipup

08/11/07 00:23:57 changed by nostgard <nostgard@yahoo.com>

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.

08/11/07 00:25:07 changed by nostgard <nostgard@yahoo.com>

  • attachment query.py.4.diff added.

clones and uses _recurse_fields

08/14/07 23:52:40 changed by SmileyChris

  • owner changed from adrian to mtredinnick.
  • stage changed from Unreviewed to Design decision needed.

Haven't heard from Malcolm about it yet.

08/20/07 11:09:24 changed by anonymous

  • cc set to jesse.lovelace@gmail.com.

09/13/07 16:46:21 changed by mtredinnick

  • keywords set to qs-rf.

10/29/07 01:22:45 changed by anonymous

  • cc changed from jesse.lovelace@gmail.com to jesse.lovelace@gmail.com, tailofthesun@gmail.com.

11/01/07 10:06:13 changed by gav

  • cc changed from jesse.lovelace@gmail.com, tailofthesun@gmail.com to jesse.lovelace@gmail.com, tailofthesun@gmail.com, gav@thataddress.com.

12/09/07 00:24:18 changed by mtredinnick

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

12/18/07 23:56:14 changed by mtredinnick

  • keywords changed from qs-rf to qs-rf-fixed.

01/03/08 02:03:32 changed by SmileyChris

  • stage changed from Design decision needed to Accepted.

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

04/26/08 21:50:16 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(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


Add/Change #5020 (select_related() implicit joins)




Change Properties
Action