Last active
August 29, 2015 14:03
-
-
Save jawnb/cd7a899cac5300c01709 to your computer and use it in GitHub Desktop.
django orm is terrible
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [9]: print User.objects.extra(select={'foo': 'bar'}).query | |
SELECT (bar) AS "foo", "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" | |
In [10]: print User.objects.extra(select={'foo': 'bar'}).annotate().query | |
SELECT (bar) AS "foo", "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" GROUP BY "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined", (bar) | |
There is no way to not group by your extra field. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment