You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "uranusjr (via GitHub)" <gi...@apache.org> on 2023/06/08 07:16:42 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #31772: Refactor Sqlalchemy queries to 2.0 styles (Part 2)

uranusjr commented on code in PR #31772:
URL: https://github.com/apache/airflow/pull/31772#discussion_r1222560471


##########
airflow/api_connexion/endpoints/xcom_endpoint.py:
##########
@@ -93,15 +93,20 @@ def get_xcom_entry(
 ) -> APIResponse:
     """Get an XCom entry."""
     if deserialize:
-        query = session.query(XCom, XCom.value)
+        query = select(XCom, XCom.value)
     else:
-        query = session.query(XCom)
+        query = select(XCom)
 
-    query = query.filter(XCom.dag_id == dag_id, XCom.task_id == task_id, XCom.key == xcom_key)
+    query = query.where(XCom.dag_id == dag_id, XCom.task_id == task_id, XCom.key == xcom_key)
     query = query.join(DR, and_(XCom.dag_id == DR.dag_id, XCom.run_id == DR.run_id))
-    query = query.filter(DR.run_id == dag_run_id)
+    query = query.where(DR.run_id == dag_run_id)
+
+    # TODO: Unify the query. Can't figure it out right now.
+    if deserialize:
+        item = session.execute(query).one_or_none()
+    else:
+        item = session.scalars(query).one_or_none()

Review Comment:
   I think this fine actually.



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