On Sep 29, 2:24 am, SeanOC <sean.b.ocon...@gmail.com> wrote:
> During the Djangocon sprints I started to work on a patch which would
> add a nicer interface for dealing with raw SQL queries.  While there I
> talked to RKM about where it should fit into the ORM API and where in
> the code base should live.  I've finally gotten around to finishing
> the code I wrote during the sprint and have posted a patch to the
> related ticket (http://code.djangoproject.com/ticket/11863).  You can
> also get the code fromhttp://github.com/SeanOC/django.

I've had a bit of a think about this, and there are a couple of things
I'd be very keen on seeing supported by this feature. I have a nasty
feeling they won't be that straight forward though.

The first is that I'd like it to be compatible with deferred loading
of model attributes - I haven't looked in to it, but my hunch is that
this won't be too hard (it might even work in its present form without
any further changes).

The second one is probably a lot harder - it feels to me like this
feature would be much more useful if it could perform select_related
style graph population. One of the key use-cases for raw SQL is
improving performance - writing queries which perform better than the
ORM (SQL optimisations, or queries that hit an alternative view or use
a stored procedure or similar). It's very plausible that a developer
might want to write a custom query that populates a full graph of
objects, just like select_related() does. It would be really useful if
the QuerySet.raw() method let them do that.

I haven't looked at how much work it would be to support graph
population - it will certainly complicate the user-facing API, and it
might require a bunch of work at the ORM level. If it's just too much
hassle I think the feature would be worth including without it, but
it's certainly worth some further investigation.

Cheers,

Simon
--~--~---------~--~----~------------~-------~--~----~
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