[Django] #20963: order_by interaction with "brew" distribution of Python 2.7.5 introduces edge-case regression

6 views
Skip to first unread message

Django

unread,
Aug 23, 2013, 3:52:00 PM8/23/13
to django-...@googlegroups.com
#20963: order_by interaction with "brew" distribution of Python 2.7.5 introduces
edge-case regression
-------------------------------------+-------------------------------------
Reporter: ptone | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: 1.6-beta-1
layer (models, ORM) | Keywords:
Severity: Normal | Has patch: 0
Triage Stage: | Needs tests: 0
Unreviewed | Easy pickings: 0
Needs documentation: 0 |
Patch needs improvement: 0 |
UI/UX: 0 |
-------------------------------------+-------------------------------------
This commit:

https://github.com/django/django/commit/69597e5bcc89aadafd1b76abf7efab30ee0b8b1a

introduced a change that interacts with the OS X specific "brew"
installation of Python 2.7.5 to result in a regression in one test.

{{{
FAIL: test_tickets_2076_7256 (regressiontests.queries.tests.Queries1Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/Users/admin/Desktop/django/tests/regressiontests/queries/tests.py", line
437, in test_tickets_2076_7256
['<Item: one>', '<Item: two>', '<Item: one>', '<Item: two>', '<Item:
four>']
File "/Users/admin/Desktop/django/django/test/testcases.py", line 776,
in assertQuerysetEqual
return self.assertEqual(list(items), values)
AssertionError: Lists differ: [] != [u'<Item: one>', u'<Item: two>...

Second list contains 5 additional elements.
First extra element 0:
<Item: one>

- []
+ [u'<Item: one>',
+ u'<Item: two>',
+ u'<Item: one>',
+ u'<Item: two>',
+ u'<Item: four>']

----------------------------------------------------------------------
Ran 1 test in 0.033s

FAILED (failures=1)
}}}

This is limited only to this patched distribution of Python. Unfortunately
this is a rather common version to be running on developer machines.

This gist shows this error on a clean machine with the brew version of
2.7.5, and the python.org binary install version of 2.7.5

The crux of the issue can be seen in this PDB session started from the
failing test:

{{{
(Pdb) Item.objects.filter(tags__isnull=False)
[<Item: four>, <Item: one>, <Item: one>, <Item: two>, <Item: two>]
(Pdb) Item.objects.filter(tags__isnull=False).order_by('tags')
[]
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/20963>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 23, 2013, 3:53:48 PM8/23/13
to django-...@googlegroups.com
#20963: order_by interaction with "brew" distribution of Python 2.7.5 introduces
edge-case regression
-------------------------------------+-------------------------------------
Reporter: ptone | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version:
(models, ORM) | 1.6-beta-1
Severity: Normal | Resolution:
Keywords: | Triage Stage:
Has patch: 0 | Unreviewed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by ptone:

Old description:

New description:

This commit:

https://github.com/django/django/commit/69597e5bcc89aadafd1b76abf7efab30ee0b8b1a

FAILED (failures=1)
}}}

https://gist.github.com/ptone/0764601b524fb87a690d

The crux of the issue can be seen in this PDB session started from the
failing test:

{{{
(Pdb) Item.objects.filter(tags__isnull=False)
[<Item: four>, <Item: one>, <Item: one>, <Item: two>, <Item: two>]
(Pdb) Item.objects.filter(tags__isnull=False).order_by('tags')
[]
}}}

--

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

Django

unread,
Aug 23, 2013, 3:58:46 PM8/23/13
to django-...@googlegroups.com
#20963: order_by interaction with "brew" distribution of Python 2.7.5 introduces
edge-case regression
-------------------------------------+-------------------------------------
Reporter: ptone | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version:
(models, ORM) | 1.6-beta-1
Severity: Normal | Resolution:
Keywords: | Triage Stage:
Has patch: 0 | Unreviewed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by ptone):

I'm inclined to not consider this a blocker, as it shouldn't effect
production systems, and we can alert the homebrew project to fix their
version.

It would be nice to track down what part of their patch is causing this,
but that is going to be outside my abilities.

But this could lead to some unfortunate head scratching by developers, and
may warrant a warning in the release notes?

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

Django

unread,
Aug 23, 2013, 4:16:18 PM8/23/13
to django-...@googlegroups.com
#20963: order_by interaction with "brew" distribution of Python 2.7.5 introduces
edge-case regression
-------------------------------------+-------------------------------------
Reporter: ptone | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version:
(models, ORM) | 1.6-beta-1
Severity: Normal | Resolution:
Keywords: | Triage Stage:
Has patch: 0 | Unreviewed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by ptone):

ref #20964, another brew related issue

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

Django

unread,
Aug 24, 2013, 5:42:08 AM8/24/13
to django-...@googlegroups.com
#20963: order_by interaction with "brew" distribution of Python 2.7.5 introduces
edge-case regression
-------------------------------------+-------------------------------------
Reporter: ptone | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version:
(models, ORM) | 1.6-beta-1
Severity: Normal | Resolution:
Keywords: | Triage Stage:
Has patch: 0 | Unreviewed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by loic84):

For the record, I think there might be similarities between the query from
this test and the scenario described by @akaariai in
https://code.djangoproject.com/ticket/20842#comment:3.

--
Ticket URL: <https://code.djangoproject.com/ticket/20963#comment:4>

Django

unread,
Aug 24, 2013, 7:58:57 PM8/24/13
to django-...@googlegroups.com
#20963: order_by interaction with "brew" distribution of Python 2.7.5 introduces
edge-case regression
-------------------------------------+-------------------------------------
Reporter: ptone | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version:
(models, ORM) | 1.6-beta-1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timo):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/20963#comment:5>

Django

unread,
Aug 25, 2013, 3:38:44 AM8/25/13
to django-...@googlegroups.com
#20963: order_by interaction with "brew" distribution of Python 2.7.5 introduces
edge-case regression
-------------------------------------+-------------------------------------
Reporter: ptone | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version:
(models, ORM) | 1.6-beta-1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by aaugustin):

FWIW my inclination is to close this kind platform-specific edge-cases as
wontfix. Homebrew is especially unreliable; its users should be aware that
that they're living on the edge.

--
Ticket URL: <https://code.djangoproject.com/ticket/20963#comment:6>

Django

unread,
Aug 26, 2013, 4:53:50 AM8/26/13
to django-...@googlegroups.com
#20963: order_by interaction with "brew" distribution of Python 2.7.5 introduces
edge-case regression
-------------------------------------+-------------------------------------
Reporter: ptone | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version:
(models, ORM) | 1.6-beta-1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by akaariai):

It would be interesting to see what is actually happening here. Getting
empty list seems very strange. It doesn't look to be the same thing as
discussed in #20842. What does the query look like, that is what does
str(qs.query) return for the failing case?

Unfortunately I don't have access to the brew version of Python, so I
can't test this. It seems likely that this is brew version doing something
weird, and in that case I don't think it is Django's responsibility to fix
this.

--
Ticket URL: <https://code.djangoproject.com/ticket/20963#comment:7>

Django

unread,
Aug 26, 2013, 5:13:55 AM8/26/13
to django-...@googlegroups.com
#20963: order_by interaction with "brew" distribution of Python 2.7.5 introduces
edge-case regression
-------------------------------------+-------------------------------------
Reporter: ptone | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version:
(models, ORM) | 1.6-beta-1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by loic84):

Model: `tests.queries.models.Item`

{{{
-- Item.objects.filter(tags__isnull=False).order_by('tags').query

SELECT "queries_item"."id", "queries_item"."name",
"queries_item"."created", "queries_item"."modified",
"queries_item"."creator_id", "queries_item"."note_id" FROM "queries_item"
INNER JOIN "queries_item_tags" ON ( "queries_item"."id" =
"queries_item_tags"."item_id" ) INNER JOIN "queries_tag" ON (
"queries_item_tags"."tag_id" = "queries_tag"."id" ) WHERE
"queries_item_tags"."tag_id" IS NOT NULL ORDER BY "queries_tag"."name" ASC

-- Item.objects.filter(tags__isnull=False).query

SELECT "queries_item"."id", "queries_item"."name",
"queries_item"."created", "queries_item"."modified",
"queries_item"."creator_id", "queries_item"."note_id" FROM "queries_item"
INNER JOIN "queries_item_tags" ON ( "queries_item"."id" =
"queries_item_tags"."item_id" ) INNER JOIN "queries_note" ON (
"queries_item"."note_id" = "queries_note"."id" ) WHERE
"queries_item_tags"."tag_id" IS NOT NULL ORDER BY "queries_note"."note"
DESC, "queries_item"."name" ASC
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/20963#comment:8>

Django

unread,
Aug 26, 2013, 6:36:11 AM8/26/13
to django-...@googlegroups.com
#20963: order_by interaction with "brew" distribution of Python 2.7.5 introduces
edge-case regression
-------------------------------------+-------------------------------------
Reporter: ptone | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version:
(models, ORM) | 1.6-beta-1
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by akaariai):

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


Comment:

loic84 verified that the issue is Brew's SQLite. It doesn't return correct
results for the .order_by('tags') query. The second INNER JOIN is removing
rows that shouldn't be removed. The same test passes on PostgreSQL and
MySQL.

I don't think it is a good idea to have release notes about bugs in Brew's
SQLite. So, closing as invalid.

--
Ticket URL: <https://code.djangoproject.com/ticket/20963#comment:9>

Django

unread,
Aug 26, 2013, 8:46:20 PM8/26/13
to django-...@googlegroups.com
#20963: order_by interaction with "brew" distribution of Python 2.7.5 introduces
edge-case regression
-------------------------------------+-------------------------------------
Reporter: ptone | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version:
(models, ORM) | 1.6-beta-1
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by ptone):

I don't disagree with closing the ticket - hopefully this won't bite
anyone too badly on their dev setup - as it will be a pain to track down
the issue. Hopefully at least they will find this ticket which documents
the issue.

--
Ticket URL: <https://code.djangoproject.com/ticket/20963#comment:10>

Django

unread,
Aug 26, 2013, 8:56:10 PM8/26/13
to django-...@googlegroups.com
#20963: order_by interaction with "brew" distribution of Python 2.7.5 introduces
edge-case regression
-------------------------------------+-------------------------------------
Reporter: ptone | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version:
(models, ORM) | 1.6-beta-1
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by ptone):

For cross reference, opened this issue on the HomeBrew project

https://github.com/mxcl/homebrew/issues/22134

--
Ticket URL: <https://code.djangoproject.com/ticket/20963#comment:11>

Django

unread,
Aug 27, 2013, 6:01:41 AM8/27/13
to django-...@googlegroups.com
#20963: order_by interaction with "brew" distribution of Python 2.7.5 introduces
edge-case regression
-------------------------------------+-------------------------------------
Reporter: ptone | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version:
(models, ORM) | 1.6-beta-1
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by github@…):

> Homebrew is especially unreliable; its users should be aware that that
they're living on the edge.

Seems solved by going even closer to the edge: SQLite 3.8.0 seems to fix
this (you need to `brew update`, `brew upgrade sqlite` and `brew reinstall
python`.

--
Ticket URL: <https://code.djangoproject.com/ticket/20963#comment:12>

Reply all
Reply to author
Forward
0 new messages