ephraimbuddy commented on code in PR #31569:
URL: https://github.com/apache/airflow/pull/31569#discussion_r1209025623


##########
airflow/jobs/job.py:
##########
@@ -252,16 +252,16 @@ def most_recent_job(job_type: str, session: Session = 
NEW_SESSION) -> Job | None
     :param job_type: job type to query for to get the most recent job for
     :param session: Database session
     """
-    return (
-        session.query(Job)
-        .filter(Job.job_type == job_type)
+    return session.scalars(

Review Comment:
   I wonder why they didn't use scalar in their 1.4/2 examples? scalar worked. 
Will need to do the same for other places but not sure why they didn't use it 
as an example



##########
airflow/jobs/backfill_job_runner.py:
##########
@@ -183,7 +184,7 @@ def _update_counters(self, ti_status: _DagRunTaskStatus, 
session: Session) -> No
 
         filter_for_tis = TI.filter_for_tis(list(ti_status.running.values()))
         if filter_for_tis is not None:
-            refreshed_tis = session.query(TI).filter(filter_for_tis).all()
+            refreshed_tis = 
session.execute(select(TI).where(filter_for_tis)).scalars().all()

Review Comment:
   Yes. Both are the same. I agree to a different PR to remove` all()`



-- 
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]

Reply via email to