Hi Anssi,

Getting back to this, a year later...I've created a branch on my fork and 
opened a ticket on Trac.

My feature branch: 
https://github.com/AlexHill/django/compare/master...raw_subqueries

Ticket on Trac, with more responses based on your comments above: 
https://code.djangoproject.com/ticket/21604

Would love to get some feedback.

Cheers,
Alex

On Friday, September 7, 2012 5:34:16 PM UTC+8, Anssi Kääriäinen wrote:
>
> On 6 syys, 11:22, Alex Hill <[email protected]> wrote: 
> > Hi Anssi, 
> > 
> > Thanks for your feedback! Responses inline. 
> > 
> >   1. It should not be assumed that the primary key is the field needed 
> > 
> > > in the inner query. We do have foreign keys to other fields, and one 
> > > can use this approach without foreign keys at all. 
> > 
> > Hmm, yes. Thinking about it, this seems like the biggest obstacle to 
> > implementing the query-wrapping approach. 
> > 
> > The reason I proposed just selecting the PK was to mirror the behaviour 
> of 
> > QuerySet when passed to __in, as happens here: 
> > 
> > https://github.com/django/django/blob/master/django/db/models/query.p... 
>
> > 
> > But since we're talking about raw SQL, we'd want maximum flexibility - 
> so 
> > would we need to introduce a ValuesRawQuerySet in order to select 
> arbitrary 
> > columns? It seems that would be the approach that most closely mirrors 
> > QuerySet. 
>
> The ValuesRawQuerySet might be a good idea. Granted, the use cases for 
> it are hard to come by apart of support for subqueries... One might 
> say we have implemented a really fancy way to do cursor.execute(); 
> cursor.fetchall()... :) 
>
> Another way is to have a pre_subselect hook, and wrap the raw SQL with 
> the right column selected automatically using that. 
>
>  - Anssi 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/857f62f4-6009-4b40-a9fe-464371f12290%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to