Opened 6 years ago

Closed 21 months ago

#10739 closed Bug (needsinfo)

MySQL and order_by()

Reported by: stephaner Owned by: nobody
Component: Database layer (models, ORM) Version: master
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 kmtracey)

I've found a strange bug in our Damned Lies application (Open Source), so I've added a test case
http://svn.gnome.org/viewvc/damned-lies?view=revision&revision=1528 to identify it.

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

actions_db[0]
<ActionDb: RT (1)>

len(actions_db)
6

actions_db[0]
<ActionDb: UNDO (6)>

Attachments (1)

vertimus.tar.gz (783 bytes) - added by stephaner 6 years ago.
Contains really small files (models.py, tests.py and JSON dump)

Download all attachments as: .zip

Change History (12)

comment:1 Changed 6 years ago by kmtracey

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Reformatted description. Please use preview.

comment:2 Changed 6 years ago by russellm

  • Resolution set to invalid
  • Status changed from new to closed

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 Changed 6 years ago by stephaner

Russel,
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!

Changed 6 years ago by stephaner

Contains really small files (models.py, tests.py and JSON dump)

comment:4 Changed 6 years ago by stephaner

  • milestone changed from 1.0.3 to 1.1
  • Resolution invalid deleted
  • Status changed from closed to reopened
  • Version changed from 1.0 to SVN

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)!
        len(actions_db)
        self.assertEqual(actions_db[0].name, 'UNDO')

comment:5 Changed 6 years ago by russellm

  • milestone 1.1 deleted

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

comment:6 Changed 6 years ago by Alex

  • Triage Stage changed from Unreviewed to Accepted

comment:7 Changed 4 years ago by SmileyChris

  • Severity set to Normal
  • Type set to Bug

comment:8 Changed 3 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:9 Changed 3 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:10 Changed 2 years ago by aaugustin

  • Status changed from reopened to new

comment:11 Changed 21 months ago by akaariai

  • Resolution set to needsinfo
  • Status changed from new to closed

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