diff --git a/airflow/api_fastapi/db/dags.py b/airflow/api_fastapi/db/dags.py index 4ed696bb09d1..7cd7cc9cd955 100644 --- a/airflow/api_fastapi/db/dags.py +++ b/airflow/api_fastapi/db/dags.py @@ -43,4 +43,5 @@ and DagRun.dag_id == latest_dag_run_per_dag_id_cte.c.dag_id, isouter=True, ) + .order_by(DagModel.dag_id) ) diff --git a/airflow/api_fastapi/parameters.py b/airflow/api_fastapi/parameters.py index 59253b8315b9..504014602f3b 100644 --- a/airflow/api_fastapi/parameters.py +++ b/airflow/api_fastapi/parameters.py @@ -176,6 +176,10 @@ def to_orm(self, select: Select) -> Select: # MySQL does not support `nullslast`, and True/False ordering depends on the # database implementation. nullscheck = case((column.isnot(None), 0), else_=1) + + # Reset default sorting + select = select.order_by(None) + if self.value[0] == "-": return select.order_by(nullscheck, column.desc(), DagModel.dag_id.desc()) else: