Yeah I'm wary that a lot of the problems with extra() will be replicated by
users switching to RawSQL() instead. It won't handle realiasing or group by
correctly.
On Tuesday, 8 December 2015 18:26:52 UTC+11, Anssi Kääriäinen wrote:
>
>
>
> On Tuesday, December 8, 2015 at 3:16:20 AM UTC+2, Michael wrote:
>>
>> I have the same problem.
>>
>> I tried to use `extra` but then I can't filter so it's not the best.
>>
>> Anybody has more info or a workaround?
>>
>
> Come to think of it, we already have a workaround:
> Book.objects.annotate(author_cnt=RawSQL("(select count(*) from author
> where author.book_id = book.book_id)").
> The fact that you can do subselects with models.RawSQL is something that a
> lot of users seem to miss. There are a couple of reasons why one shouldn't
> use RawSQL too much, like the way it hard codes column names and table
> aliases.
>
> - Anssi
>
--
You received this message because you are subscribed to the Google Groups
"Django developers (Contributions to Django itself)" 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/29a5a198-28c5-4339-9786-cd3d5e799b81%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.