#25272: Query doesn't include `ORDER BY` statement in subquery ----------------------------------------------+-------------------- Reporter: aykut | Owner: nobody Type: Bug | Status: new Component: Database layer (models, ORM) | Version: 1.6 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 ----------------------------------------------+-------------------- I faced this in Django 1.6.x. Please notice `ORDER BY` is not included in subquery.
{{{ In [1]: profiles=UserProfile.objects.order_by('pk')[:10] In [2]: print User.objects.filter(userprofile__in=profiles).query SELECT "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" INNER JOIN "accounts_userprofile" ON ( "auth_user"."id" = "accounts_userprofile"."user_id" ) WHERE "accounts_userprofile"."id" IN (SELECT "accounts_userprofile"."id" FROM "accounts_userprofile" LIMIT 10) }}} I also tried this same case on a project running Django 1.8.3, the printed query was correct as expected. -- Ticket URL: <https://code.djangoproject.com/ticket/25272> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/048.d76f447e530b113719586691248982d9%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.