Prab-27 commented on code in PR #59823:
URL: https://github.com/apache/airflow/pull/59823#discussion_r2649537177
##########
airflow-core/tests/unit/jobs/test_scheduler_job.py:
##########
@@ -3486,7 +3492,9 @@ def my_task(): ...
self.job_runner._do_scheduling(session)
assert (
- session.query(DagRun).filter(DagRun.dag_id == dr.dag_id,
DagRun.run_id == dr.run_id).one().state
+ session.scalars(select(DagRun).where(DagRun.dag_id == dr.dag_id,
DagRun.run_id == dr.run_id))
+ .one()
+ .state
Review Comment:
@kunaljubce, I thought only two test cases pass, and we are asserting only a
scalar Python value while dealing with a single table.
So I thought we could use .scalar() here because there is a low chance of
duplicate rows. .scalar() returns the first row’s like (.one() ) (or None), so
it can be used in the assertion.
However, the strict assertion (.one() / scalar_one()) also works and is
safer because it enforces exactly one row or raises an error.
--
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]