uranusjr commented on a change in pull request #14895:
URL: https://github.com/apache/airflow/pull/14895#discussion_r599164365
##########
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 wonder if we should have a definition of what models, and what fields
on each model can be filtered on, either on the model classes themselves, or in
a separate mapping maintained in `api_connexion`. (It should be a positive list
so data won’t be leaked when a new model field is added.)
--
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]