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


##########
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(
+        select(Job)
+        .where(Job.job_type == job_type)
         .order_by(
             # Put "running" jobs at the front.
             case({State.RUNNING: 0}, value=Job.state, else_=1),
             Job.latest_heartbeat.desc(),
         )
-        .first()
-    )
+        .limit(1)
+    ).first()

Review Comment:
   ```python
   return session.scalar(
       select(Job)
       .where(Job.job_type == job_type)
       .order_by(...)
       .limit(1)
   )
   ```
   
   I think this would be 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]

Reply via email to