Django

Code

Ticket #6088 (closed: fixed)

Opened 6 months ago

Last modified 3 weeks ago

get_previous_in_order broken

Reported by: James Wheare <django@sparemint.com> Assigned to: nobody
Component: Database wrapper Version: SVN
Keywords: qs-rf-fixed Cc:
Triage Stage: Accepted Has patch: 1
Needs documentation: 0 Needs tests: 0
Patch needs improvement: 0

Description

There's a bug in the SQL generated when calling get_previous_in_order. Luckily looks like a quick fix from where I'm sitting. Just need to change the ordering to DESC from ASC.

Attachments

_get_next_or_previous_in_order.diff (0.7 kB) - added by James Wheare <django@sparemint.com> on 12/01/07 15:10:14.

Change History

12/01/07 15:10:14 changed by James Wheare <django@sparemint.com>

  • attachment _get_next_or_previous_in_order.diff added.

12/01/07 15:15:23 changed by James Wheare <django@sparemint.com>

  • needs_better_patch changed.
  • has_patch set to 1.
  • needs_tests changed.
  • needs_docs changed.

This is the SQL run when calling get_next_in_order on a "model" object with _order 24

SELECT * FROM app_model WHERE fk = 1 AND _order > 24 ORDER BY app_model._order ASC LIMIT 1;

And here's get_previous_in_order on the same object

SELECT * FROM app_model WHERE fk = 1 AND _order < 24 ORDER BY app_model._order ASC LIMIT 1;

The patch changes that second query to use DESC instead.

12/01/07 15:16:33 changed by mtredinnick

  • keywords set to qs-rf.

I'll fix this on queryset-refactor, rather than trunk, but it looks basically correct.

12/09/07 00:12:09 changed by mtredinnick

  • keywords changed from qs-rf to qs-rf-fixed.

Through the magic of time machines, I fixed this back in [6486].

I'll note in passing, though, that the patch on this ticket isn't correct. The idiom

is_next and '' or '-'

is invalid when the second argument to the "and" portion evaluates to False. This expression will always return '-', regardless of the value of is_next. The code in [6486] avoids this trap.

Ticket will be closed when queryset-refactor is merged into trunk.

01/03/08 02:04:09 changed by SmileyChris

  • stage changed from Unreviewed to Accepted.

Promoting to accepted: if it's fixed in the queryset refactor then it has obviously an accepted issue (even if the ticket isn't correct)

04/26/08 21:50:16 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [7477]) Merged the queryset-refactor branch into trunk.

This is a big internal change, but mostly backwards compatible with existing code. Also adds a couple of new features.

Fixed #245, #1050, #1656, #1801, #2076, #2091, #2150, #2253, #2306, #2400, #2430, #2482, #2496, #2676, #2737, #2874, #2902, #2939, #3037, #3141, #3288, #3440, #3592, #3739, #4088, #4260, #4289, #4306, #4358, #4464, #4510, #4858, #5012, #5020, #5261, #5295, #5321, #5324, #5325, #5555, #5707, #5796, #5817, #5987, #6018, #6074, #6088, #6154, #6177, #6180, #6203, #6658


Add/Change #6088 (get_previous_in_order broken)




Change Properties
Action