Support ORDER BY BINARY in MySQL
|Reported by:||Owned by:||anonymous|
|Component:||Database layer (models, ORM)||Version:||master|
|Severity:||Normal||Keywords:||mysql, binary, order by|
|Cc:||mmitar@…||Triage Stage:||Design decision needed|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Description (last modified by )
MySQL supports both ORDER BY and ORDER BY BINARY.
ORDER BY does NOT match the string sort used by Python but ORDER BY BINARY DOES. Lots of issues arise when returned list from DB needs to be in proper order.
The problem is described well at: http://blog.awarelabs.com/?p=18 (article by the reporter of this ticket)
The Proposed Fix:
__binary tag to the end of any
order_by('column') caluse, like so
__binary tag before any processing and ensure 'BINARY ' is inserted into generated SQL.
The above solution ensures existing behavior is not altered. It does carry the side effect of making
__binary a reserved word which come to think of it is reserved in SQL so no issue there.
Change History (11)
comment:3 Changed 8 years ago by
|Triage Stage:||Ready for checkin → Design decision needed|
comment:9 Changed 5 years ago by
|Status:||assigned → closed|