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 2022/01/14 12:16:09 UTC

[GitHub] [airflow] ashb commented on a change in pull request #20871: Fix failing main

ashb commented on a change in pull request #20871:
URL: https://github.com/apache/airflow/pull/20871#discussion_r784797299



##########
File path: airflow/api_connexion/endpoints/task_instance_endpoint.py
##########
@@ -326,7 +326,12 @@ def post_set_task_instances_state(*, dag_id: str, session: Session = NEW_SESSION
             detail=f"Task instance not found for task {task_id!r} on execution_date {execution_date}"
         )
 
-    if run_id and not session.query(TI).get({'task_id': task_id, 'dag_id': dag_id, 'run_id': run_id}):
+    if run_id and (
+        session.query(TI)
+        .filter(TI.task_id == task_id, TI.dag_id == dag_id, TI.run_id == run_id)
+        .one_or_none()
+        is None
+    ):

Review comment:
       tests/api_connexion/endpoints/test_task_instance_endpoint.py::TestPostSetTaskInstanceState::test_should_assert_call_mocked_api_when_run_id: sqlalchemy.exc.InvalidRequestError: Incorrect number of values in identifier to formulate primary key for query.get(); primary key columns are 'task_instance.task_id','task_instance.dag_id','task_instance.run_id','task_instance.map_index'
   
   ```suggestion
   if run_id and not session.query(TI).get({'task_id': task_id, 'dag_id': dag_id, 'run_id': run_id, 'map_index': -1}):    ):
   ```




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