Hi Luke,

On Oct 3, 9:04 am, Luke Plant <l.plant...@cantab.net> wrote:
> The patch for this is now ready, as far as I'm concerned, but I'd like
> to bring it up here again before committing, mainly because Alex Gaynor
> expressed some doubts.
>
> The latest patch is on the ticket:
>
> https://code.djangoproject.com/ticket/16937

I know I'm a bit late to the party here (had a work deadline last
Friday). I think this functionality is valuable and makes sense to
have in the ORM, thanks for all the work on it. Though I don't have
time to go through the patch in detail, it seems like its gotten
several pairs of eyes over it closely already.

My only real concern is one I'm a bit surprised hasn't been raised
already: API and naming sanity. If I'm a new user coming to this API,
as far as I'm concerned "select_related" and "prefetch_related" may as
well be synonyms - they don't tell me anything useful about how the
functions differ. And even knowing the internal details, any
justification for the naming seems tortured at best: both methods use
selects, and both prefetch something that would otherwise have to be
fetched separately later.

Given that this and select_related operate on entirely disjoint sets
of fields, is there a good technical reason not to simply merge this
functionality into select_related? Sure, the underlying implementation
is quite different, but philosophically the ORM doesn't generally aim
to be a transparent reflection of what's happening at the SQL layer,
it aims to present a coherent object API. At that level I think
select_related and prefetch_related are pretty much indistinguishable
from each other. A note in the docs that using select_related on an
m2m will result in an extra query (but many fewer than if you didn't
use it and iterated over the m2m related objects for each row!) seems
to me a quite adequate nod to the implementation difference.

As the builder of the bikeshed, you get to paint it, so if you've
already considered all this and haven't come up with any better API
naming options, I'll withdraw my concern. But it seems to me it's at
least worth some public discussion before locking ourselves into an
API.

Carl

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to