uranusjr commented on a change in pull request #18421:
URL: https://github.com/apache/airflow/pull/18421#discussion_r713752452
##########
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:
Docs say `scalar()` fails if there’s more than one row
https://docs.sqlalchemy.org/en/14/orm/query.html#sqlalchemy.orm.Query.scalar
--
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]