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/04/04 11:28:28 UTC

[GitHub] [airflow] kaxil commented on a change in pull request #15174: raise AlreadyExists exception when the execution_date is same

kaxil commented on a change in pull request #15174:
URL: https://github.com/apache/airflow/pull/15174#discussion_r606788179



##########
File path: airflow/api_connexion/endpoints/dag_run_endpoint.py
##########
@@ -240,14 +241,26 @@ def post_dag_run(dag_id, session):
         post_body = dagrun_schema.load(request.json, session=session)
     except ValidationError as err:
         raise BadRequest(detail=str(err))
+
     dagrun_instance = (
-        session.query(DagRun).filter(DagRun.dag_id == dag_id, DagRun.run_id == post_body["run_id"]).first()
+        session.query(DagRun)
+        .filter(
+            or_(DagRun.run_id == post_body["run_id"], DagRun.execution_date == post_body["execution_date"])
+        )

Review comment:
       Why not include `dag_id` as a filter, why scan all DAG IDs
   
   ```suggestion
           .filter(DagRun.dag_id == dag_id,
               or_(DagRun.run_id == post_body["run_id"], DagRun.execution_date == post_body["execution_date"])
           )
   ```




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

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