Ticket #595: django-custom-select-desc-fix.patch
File django-custom-select-desc-fix.patch, 1.4 KB (added by , 19 years ago) |
---|
-
__init__.py
1332 1463 if f == '?': # Special case. 1333 1464 order_by.append(db.get_random_function_sql()) 1334 1465 else: 1466 if f.startswith('-'): 1467 col_name = f[1:] 1468 order = "DESC" 1469 else: 1470 col_name = f 1471 order = "ASC" 1335 1472 # Use the database table as a column prefix if it wasn't given, 1336 1473 # and if the requested column isn't a custom SELECT. 1337 if "." not in f and fnot in [k[0] for k in kwargs.get('select', [])]:1474 if "." not in col_name and col_name not in [k[0] for k in kwargs.get('select', [])]: 1338 1475 table_prefix = opts.db_table + '.' 1339 1476 else: 1340 1477 table_prefix = '' 1341 if f.startswith('-'): 1342 order_by.append('%s%s DESC' % (table_prefix, orderfield2column(f[1:], opts))) 1343 else: 1344 order_by.append('%s%s ASC' % (table_prefix, orderfield2column(f, opts))) 1478 1479 order_by.append('%s%s %s' % (table_prefix, orderfield2column(col_name, opts), order)) 1480 1345 1481 order_by = ", ".join(order_by) 1346 1482 1347 1483 # LIMIT and OFFSET clauses