Opened 15 years ago

Closed 10 years ago

#10739 closed Bug (needsinfo)

MySQL and order_by()

Reported by: Stephane Raimbault Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Karen Tracey)

I've found a strange bug in our Damned Lies application (Open Source), so I've added a test case to identify it.

[<ActionDb: UNDO (6)>, <ActionDb: RP (5)>, <ActionDb: UT (4)>, <ActionDb: RT (3)>, <ActionDb: UNDO (2)>, <ActionDb: RT (1)>]

<ActionDb: RT (1)>


<ActionDb: UNDO (6)>

Attachments (1)

vertimus.tar.gz (783 bytes ) - added by Stephane Raimbault 15 years ago.
Contains really small files (, and JSON dump)

Download all attachments as: .zip

Change History (12)

comment:1 by Karen Tracey, 15 years ago

Description: modified (diff)

Reformatted description. Please use preview.

comment:2 by Russell Keith-Magee, 15 years ago

Resolution: invalid
Status: newclosed

In addition to using preview, if you could go so far as to, say, describe the actual problem, that would be just grand.

I gather that you are getting unexpected output. The ticket title implies that the problem is related to MySQL and order_by(). Evidently a call to len() fixes the problem (or masks the problem in interesting ways).

You provide a link to a 500 line test case, of which I'm guessing maybe the last 40 lines are relevant. Of course, that test case isn't standalone, and doesn't use standard Django model calls - it's deeply embedded in an application called "Damned Lies".

Unfortunately, the fact that your project is open source doesn't mean that I'm going to find your problems for you.

I have no doubt you have found a problem. If you want to get this problem resolved, you're going to need to meet us half way - with a minimal test case for reproducing the problem. "Download Damned Lies" is not that set of instructions. If you care to provide us with a minimal test case, feel free to reopen this ticket.

comment:3 by Stephane Raimbault, 15 years ago

you're right my bug report sucks and I won't take offense for that!
You're kind to reply with a long explanation :)

I'll try to create a real bug report as soon as I've free time. The bug is really nasty because I can reproduce it on 2 of my PC but another Damned Lies developer can't so I'm intend to create a minimal Django project with fixtures and the failing test (I hope to be able to isolate the bug) then I'll test this minimal project on other Linux distributions before submitting the new report. I've also begun to test different MySQL settings.

PS: I don't like MySQL, grrr!

by Stephane Raimbault, 15 years ago

Attachment: vertimus.tar.gz added

Contains really small files (, and JSON dump)

comment:4 by Stephane Raimbault, 15 years ago

Resolution: invalid
Status: closedreopened
Version: 1.0SVN

The bug occurs on Ubuntu 8.10 (Python 2.5.2 and MySQL 5.0.67-0ubuntu6) with Django 1.0.2 and Django 1.1 (SVN) but not on Ubuntu 9.04 (Python 2.6).

def test_mysql(self):
        actions_db = ActionDb.objects.filter(state_db__id=1).exclude(name='WC').order_by('-id')

        # So the last action is UNDO
        # but 'RT' is returned!
        self.assertEqual(actions_db[0].name, 'UNDO')
        # Here be dragons! A call to len() workaround the bug (try to move it)!
        self.assertEqual(actions_db[0].name, 'UNDO')

comment:5 by Russell Keith-Magee, 15 years ago

milestone: 1.1

This doesn't appear to cause data loss, so I'm deferring this from the v1.1 schedule

comment:6 by Alex Gaynor, 15 years ago

Triage Stage: UnreviewedAccepted

comment:7 by Chris Beaven, 13 years ago

Severity: Normal
Type: Bug

comment:8 by Aymeric Augustin, 12 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:9 by Aymeric Augustin, 12 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:10 by Aymeric Augustin, 11 years ago

Status: reopenednew

comment:11 by Anssi Kääriäinen, 10 years ago

Resolution: needsinfo
Status: newclosed

I call for close of this bug. Seems to be about old versions of MySQL and/or Python, and if this was anything severe we would surely have heard more of this.

Note: See TracTickets for help on using tickets.
Back to Top