Taragolis commented on code in PR #35339:
URL: https://github.com/apache/airflow/pull/35339#discussion_r1379072906
##########
airflow/utils/cli.py:
##########
@@ -269,7 +269,7 @@ def get_dag_by_pickle(pickle_id: int, session: Session =
NEW_SESSION) -> DAG:
"""Fetch DAG from the database using pickling."""
from airflow.models import DagPickle
- dag_pickle = session.scalar(select(DagPickle).where(DagPickle.id ==
pickle_id)).first()
+ dag_pickle = session.scalar(select(DagPickle).where(DagPickle.id ==
pickle_id).limit(1))
Review Comment:
This could be run without binding session, that is a bigger benefit of "new"
SA API
```python
from sqlalchemy import select
from airflow.models import DagPickle
stmt = select(DagPickle).where(DagPickle.id == 42).limit(1)
print(stmt)
```
```console
SELECT dag_pickle.id, dag_pickle.pickle, dag_pickle.created_dttm,
dag_pickle.pickle_hash
FROM dag_pickle
WHERE dag_pickle.id = :id_1
LIMIT :param_1
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]