ephraimbuddy commented on code in PR #37761:
URL: https://github.com/apache/airflow/pull/37761#discussion_r1506181881
##########
airflow/models/xcom.py:
##########
@@ -210,15 +212,17 @@ def set(
message = "Passing 'execution_date' to 'XCom.set()' is deprecated.
Use 'run_id' instead."
warnings.warn(message, RemovedInAirflow3Warning, stacklevel=3)
try:
- dag_run_id, run_id = (
- session.query(DagRun.id, DagRun.run_id)
- .filter(DagRun.dag_id == dag_id, DagRun.execution_date ==
execution_date)
- .one()
- )
+ dag_run_id, run_id = session.execute(
+ select(DagRun.id, DagRun.run_id).where(
+ DagRun.dag_id == dag_id, DagRun.execution_date ==
execution_date
+ )
+ ).one()
except NoResultFound:
raise ValueError(f"DAG run not found on DAG {dag_id!r} at
{execution_date}") from None
else:
- dag_run_id = session.query(DagRun.id).filter_by(dag_id=dag_id,
run_id=run_id).scalar()
+ dag_run_id = session.scalars(
+ select(DagRun.id).filter_by(dag_id=dag_id, run_id=run_id)
+ ).one_or_none()
Review Comment:
```suggestion
dag_run_id = session.scalar(
select(DagRun.id).filter_by(dag_id=dag_id, run_id=run_id)
)
```
I think this is more equivalent
--
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]