You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/09/22 07:24:06 UTC

[GitHub] [airflow] ephraimbuddy commented on a change in pull request #18421: Correctly select DagRun.execution_date from db

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



##########
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:
       ```suggestion
               .scalar()
   ```
   I think using only `.scalar()` is enough. 




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org