Move orderby direction check above column expansion.
This commit is contained in:
		
							parent
							
								
									8ecf594945
								
							
						
					
					
						commit
						b1000dd0f8
					
				
					 1 changed files with 12 additions and 12 deletions
				
			
		|  | @ -324,6 +324,18 @@ def normalize_orderby(orderby, warning_bag=None): | ||||||
|                 raise exc |                 raise exc | ||||||
|             continue |             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: |         if column not in constants.ALLOWED_ORDERBY_COLUMNS: | ||||||
|             exc = ValueError(constants.WARNING_ORDERBY_BADCOL.format(column=column)) |             exc = ValueError(constants.WARNING_ORDERBY_BADCOL.format(column=column)) | ||||||
|             if warning_bag: |             if warning_bag: | ||||||
|  | @ -347,18 +359,6 @@ def normalize_orderby(orderby, warning_bag=None): | ||||||
|         elif column == 'ratio': |         elif column == 'ratio': | ||||||
|             column = '(width / height)' |             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) |         requested_order = (column, direction) | ||||||
|         final_orderby.append(requested_order) |         final_orderby.append(requested_order) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue