Ticket #7580: binary_patch.diff
File binary_patch.diff, 2.2 KB (added by , 16 years ago) |
---|
-
db/models/sql/query.py
557 557 else: 558 558 asc, desc = ORDER_DIR['DESC'] 559 559 for field in ordering: 560 binary_extra = '' 561 if field.endswith('__binary'): 562 field = field.rstrip('__binary') 563 binary_extra = 'BINARY ' 564 560 565 if field == '?': 561 566 result.append(self.connection.ops.random_function_sql()) 562 567 continue … … 566 571 field = -field 567 572 else: 568 573 order = asc 569 result.append('%s %s' % ( field, order))574 result.append('%s %s' % (binary_extra + field, order)) 570 575 continue 571 576 if '.' in field: 572 577 # This came in through an extra(order_by=...) addition. Pass it … … 575 580 table, col = col.split('.', 1) 576 581 elt = '%s.%s' % (qn(table), col) 577 582 if not distinct or elt in select_aliases: 578 result.append('%s %s' % ( elt, order))583 result.append('%s %s' % (binary_extra + elt, order)) 579 584 elif get_order_dir(field)[0] not in self.extra_select: 580 585 # 'col' is of the form 'field' or 'field1__field2' or 581 586 # '-field1__field2__field', etc. … … 584 589 elt = '%s.%s' % (qn(table), qn2(col)) 585 590 if distinct and elt not in select_aliases: 586 591 ordering_aliases.append(elt) 587 result.append('%s %s' % ( elt, order))592 result.append('%s %s' % (binary_extra + elt, order)) 588 593 else: 589 594 col, order = get_order_dir(field, asc) 590 595 elt = qn(col) 591 596 if distinct and elt not in select_aliases: 592 597 ordering_aliases.append(elt) 593 result.append('%s %s' % ( elt, order))598 result.append('%s %s' % (binary_extra + elt, order)) 594 599 self.ordering_aliases = ordering_aliases 595 600 return result 596 601