uranusjr commented on a change in pull request #18421:
URL: https://github.com/apache/airflow/pull/18421#discussion_r713776338



##########
File path: airflow/models/dag.py
##########
@@ -1269,16 +1269,17 @@ def get_task_instances_before(
         ``base_date``, or more if there are manual task runs between the
         requested period, which does not count toward ``num``.
         """
-        min_date = (
-            session.query(DagRun)
+        min_date: Optional[datetime] = (
+            session.query(DagRun.execution_date)
             .filter(
                 DagRun.dag_id == self.dag_id,
                 DagRun.execution_date <= base_date,
                 DagRun.run_type != DagRunType.MANUAL,
             )
             .order_by(DagRun.execution_date.desc())
             .offset(num)
-            .first()
+            .limit(1)
+            .scalar()

Review comment:
       I think `first()` would require unpacking the returning tuple manually? 
This feels slightly easier to read for me than
   
   ```python
   min_date_row = session.query(...).first()
   if min_date_row is None:
       ...
   min_date = min_date_row[0]
   ```




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