Skip to content

Commit

Permalink
[AIRFLOW-618] Cast DateTimes to avoid sqllite errors
Browse files Browse the repository at this point in the history
For some reason, sqllite does not always match
datetimes correctly.
This causes unit test failures, in particular the
trigger_dagrun test.
Casting the datetime explicitly appears to solve
the issue.

Closes apache#1871 from jlowin/failing-sqlite-test
  • Loading branch information
jlowin authored and bolkedebruin committed Nov 7, 2016
1 parent 286c047 commit f192770
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion airflow/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3650,9 +3650,11 @@ def refresh_from_db(self, session=None):
"""
DR = DagRun

exec_date = func.cast(self.execution_date, DateTime)

dr = session.query(DR).filter(
DR.dag_id == self.dag_id,
DR.execution_date == self.execution_date,
func.cast(DR.execution_date, DateTime) == exec_date,
DR.run_id == self.run_id
).one()

Expand Down

0 comments on commit f192770

Please sign in to comment.