guan404ming commented on code in PR #55160:
URL: https://github.com/apache/airflow/pull/55160#discussion_r2316769071


##########
airflow-core/src/airflow/models/log.py:
##########
@@ -56,6 +56,13 @@ class Log(Base):
         primaryjoin="Log.dag_id == DagModel.dag_id",
     )
 
+    task_instance = relationship(
+        "TaskInstance",
+        viewonly=True,
+        foreign_keys=[task_id],
+        primaryjoin="Log.task_id == TaskInstance.task_id",
+    )
+

Review Comment:
   So ideally the usage priority would be:
   
     1. If `SQLAlchemy` can auto-detect the relationship -> only specify 
lazy="selectin"
     2. If `SQLAlchemy` cannot auto-detect -> specify foreign_keys and 
primaryjoin explicitly
   
   I think this follows the principle of minimal configuration to only add 
explicit relationship parameters when absolutely necessary for `SQLAlchemy` to 
understand the join.



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

Reply via email to