Hi 

Just a side issue I spotted here, but I'm probably missing something,
so I'm seeking to understand.

Is this the SQL the django query builder made? If so which database
backend and django version are you using?

On Sun, 2020-07-19 at 08:30 +0100, Damanjeet Singh wrote:
> 2>SQL Query 
> 
> SELECT "urls_subdomain"."id", "urls_subdomain"."created_at",
> "urls_subdomain"."name", COUNT("urls_url"."id") AS "numItems" FROM
> "urls_subdomain" LEFT OUTER JOIN "urls_url" ON ("urls_subdomain"."id"
> = "urls_url"."subdomain_id") GROUP BY "urls_subdomain"."id" ORDER BY
> "urls_subdomain"."name" ASC

I only ask because normally in SQL the rule  is "However, each table or
view column in any nonaggregate expression in the
 <select> list must be included in the GROUP BY list" (quote from MS
TSQL docs which was just the first hit my google search found) . And
the name and create_at columns are missing in the GROUP BY clause in
the quoted SQL statement.

It seems unlikely that Django is generating invalid SQL as we would
have seen more issues (although the intent of the SQL expression above
is clear, and I have met engines which can execute it fine)

TTFN
-- 
Roger Gammans <rgamm...@gammascience.co.uk>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/58c1572c4c40a5fca010d2b3dd345bb1b65b79d0.camel%40gammascience.co.uk.

Reply via email to