ephraimbuddy commented on a change in pull request #14895:
URL: https://github.com/apache/airflow/pull/14895#discussion_r599748311
##########
File path: airflow/api_connexion/parameters.py
##########
@@ -86,3 +87,32 @@ def wrapped_function(*args, **kwargs):
return cast(T, wrapped_function)
return format_parameters_decorator
+
+
+def apply_sorting(model, query, order_by, to_replace=None):
+ """Apply sorting to query"""
+ if to_replace:
+ for key, value in to_replace.items():
+ if key == order_by:
+ order_by = value
+ if order_by.strip('-') not in (i.name for i in model.__table__.columns):
Review comment:
I decided to maintain a list of allowed attributes on the endpoint since
some models are flask appbuilder models. Let me know if this is good.
Another concern I have is that some endpoints were ordered by 'id' whereas
'id' is not in their openapi schema definition. Removing 'id' from the list of
attributes to order by in these endpoints will be a breaking change. For such
endpoints, I retained a default order by 'id'. Let me know if this is OK
@mik-laj @uranusjr
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]