[Django] #25272: Query doesn't include `ORDER BY` statement in subquery

3 views
Skip to first unread message

Django

unread,
Aug 13, 2015, 9:41:38 AM8/13/15
to django-...@googlegroups.com
#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.

Django

unread,
Aug 13, 2015, 10:13:40 AM8/13/15
to django-...@googlegroups.com
#25272: Query doesn't include `ORDER BY` statement in subquery
-------------------------------------+-------------------------------------

Reporter: aykut | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.6
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Per our [https://docs.djangoproject.com/en/dev/internals/release-process
/#supported-versions supported versions policy], 1.6 is no longer
receiving security or bug fixes. Are you saying the issue is fixed in
Django 1.8?

--
Ticket URL: <https://code.djangoproject.com/ticket/25272#comment:1>

Django

unread,
Aug 13, 2015, 10:36:02 AM8/13/15
to django-...@googlegroups.com
#25272: Query doesn't include `ORDER BY` statement in subquery
-------------------------------------+-------------------------------------

Reporter: aykut | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.6
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by aykut):

It is fixed in both 1.7 and 1.8. I've tried it on 1.7 too.

--
Ticket URL: <https://code.djangoproject.com/ticket/25272#comment:2>

Django

unread,
Aug 13, 2015, 10:48:18 AM8/13/15
to django-...@googlegroups.com
#25272: Query doesn't include `ORDER BY` statement in subquery
-------------------------------------+-------------------------------------
Reporter: aykut | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 1.6
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by aykut):

* status: new => closed
* resolution: => wontfix


--
Ticket URL: <https://code.djangoproject.com/ticket/25272#comment:3>

Reply all
Reply to author
Forward
0 new messages