On Wed, May 31, 2017 at 3:01 PM, Alceu Rodrigues de Freitas Junior <
alceu.freitas...@gmail.com> wrote:

> Hi James,
>
> I'm curious... why dropping down from the ORM and doing a single query
> wouldn't be portable?
>
> I understand that it would happen if you use some kind of stored procedure
> in the DB, but I guess a single ANSI SQL would do it.
>
> Thanks!
>
> - Alceu
>

I might have painted that statement with too broad of a brush, but the
underlying intention is correct. Sticking with the ORM ensures consistent
behavior across all supported database backends. In the case of a simple
COUNT(*) query, even with multiple tables involved, the SQL statement is
likely portable across any of the included backends.

My intention was to say that using the ORM will better guarantee that the
call is portable, not necessarily saying that raw SQL cannot or would not
be. Of course, many queries can be made that would work in any
SQL-compliant RDBMS.

At any rate, a quick Google showed that the OP is likely stuck with two
queries anyway. The SO posts, etc. show sub-SELECT statements in use in
order to get the result returned as a single data set.

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciVGXcWG65%2BGz3%3DoVP4c6YeZM8rPcorFjhe-S_xOGMytZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to