ephraimbuddy commented on a change in pull request #14895:
URL: https://github.com/apache/airflow/pull/14895#discussion_r600252555
##########
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, allowed_attrs=None):
+ """Apply sorting to query"""
+ lstriped_orderby = order_by.lstrip('-')
+ if allowed_attrs and lstriped_orderby not in allowed_attrs:
+ modelname = model.__tablename__.capitalize()
Review comment:
I couldn't find a way to get the class name of the sqlalchemy models.
So here, I'm getting the table name and capitalizing and also replacing some to
have the class name. This can be avoided, including the replacement because
it's just for error messages. I wanted the error to tell the user the table
that's being queried.
Do you have an idea on how to get the class name of an Sqlalchemy model?:
```python
class Connection(Base):
__tablename__ = 'my_connection'
```
I want to have `Connection`
--
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]