Move orderby direction check above column expansion.

This commit is contained in:
voussoir 2021-01-01 13:22:42 -08:00
parent 8ecf594945
commit b1000dd0f8

View file

@ -324,6 +324,18 @@ def normalize_orderby(orderby, warning_bag=None):
raise exc
continue
if direction not in ('asc', 'desc'):
message = constants.WARNING_ORDERBY_BADDIRECTION.format(
column=column,
direction=direction,
)
exc = ValueError(message)
if warning_bag:
warning_bag.add(exc)
else:
raise exc
direction = 'desc'
if column not in constants.ALLOWED_ORDERBY_COLUMNS:
exc = ValueError(constants.WARNING_ORDERBY_BADCOL.format(column=column))
if warning_bag:
@ -347,18 +359,6 @@ def normalize_orderby(orderby, warning_bag=None):
elif column == 'ratio':
column = '(width / height)'
if direction not in ('asc', 'desc'):
message = constants.WARNING_ORDERBY_BADDIRECTION.format(
column=column,
direction=direction,
)
exc = ValueError(message)
if warning_bag:
warning_bag.add(exc)
else:
raise exc
direction = 'desc'
requested_order = (column, direction)
final_orderby.append(requested_order)