diff -ru django/db/models/query.py /Library/Frameworks/Python.framework/Versions/Current/lib/python2.5/site-packages/django/db/models/query.py
old
|
new
|
|
529 | 529 | else: |
530 | 530 | col_name = f |
531 | 531 | order = "ASC" |
| 532 | if "(" in col_name: |
| 533 | b, e = col_name.find("("), col_name.find(")") |
| 534 | function = col_name[:b].upper() |
| 535 | col_name = col_name[b+1:e] |
| 536 | else: |
| 537 | function = None |
532 | 538 | if "." in col_name: |
533 | 539 | table_prefix, col_name = col_name.split('.', 1) |
534 | 540 | table_prefix = backend.quote_name(table_prefix) + '.' |
… |
… |
|
539 | 545 | table_prefix = backend.quote_name(opts.db_table) + '.' |
540 | 546 | else: |
541 | 547 | table_prefix = '' |
542 | | order_by.append('%s%s %s' % (table_prefix, backend.quote_name(orderfield2column(col_name, opts)), order)) |
| 548 | if function: |
| 549 | order_by.append('%s(%s%s) %s' % (function, table_prefix, backend.quote_name(orderfield2column(col_name, opts)), order)) |
| 550 | else: |
| 551 | order_by.append('%s%s %s' % (table_prefix, backend.quote_name(orderfield2column(col_name, opts)), order)) |
543 | 552 | if order_by: |
544 | 553 | sql.append("ORDER BY " + ", ".join(order_by)) |