Code

Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#3825 closed (duplicate)

crash on sorting on foreign key with default ordering desc

Reported by: David S. <davidschein@…> Owned by: adrian
Component: Database layer (models, ORM) Version: master
Severity: Keywords: ordering foreignkey
Cc: None Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: UI/UX:

Description

This bug became evident in the admin interface when selecting a column header to sort on a column that is a foreign key in the model. When the model to which it refers has a Meta.ordering that is descending on a field, then the ordering logic failed because it failed to remove the leading minus sign in the SQL.

Patch included.

Attachments (1)

query_ordering.patch (693 bytes) - added by David S. <davidschein@…> 7 years ago.
patch

Download all attachments as: .zip

Change History (7)

Changed 7 years ago by David S. <davidschein@…>

patch

comment:1 Changed 7 years ago by Simon G. <dev@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Ready for checkin

comment:2 Changed 7 years ago by mtredinnick

  • Patch needs improvement set
  • Triage Stage changed from Ready for checkin to Accepted

People need to stop using rsplit() in patches. It doesn't work with Python 2.3. Triagers, please watch out for this.

I don't understand why the rsplit() is even needed here. I understand the checking for a hyphen on the column name, but not why you are expecting multiple dots in the table name. I don't believe a sequence like table1.table2.column_name is going to work in any case -- the SQL for the table joins will be wrong, won't it?

comment:3 Changed 7 years ago by anonymous

  • Cc None added
  • Component changed from Database wrapper to django-admin.py runserver
  • Keywords None added; ordering foreignkey removed
  • Summary changed from crash on sorting on foreign key with default ordering desc to None
  • Version changed from SVN to 0.91

comment:4 Changed 7 years ago by Ramiro Morales

  • Component changed from django-admin.py runserver to Database wrapper
  • Keywords ordering foreignkey added; None removed
  • Summary changed from None to crash on sorting on foreign key with default ordering desc
  • Version changed from 0.91 to SVN

Undo anonymous breakage of tickets

comment:5 Changed 7 years ago by gwilson

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

duplicate of #2895.

comment:6 Changed 7 years ago by anonymous

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.