kaxil commented on PR #43243:
URL: https://github.com/apache/airflow/pull/43243#issuecomment-2439774584

   After updating the primary key on the `TaskInstance` model to a UUID7 `id` 
field (from the composite primary key of `["dag_id", "task_id", "run_id", 
"map_index"]`), I have now run into issues with using `session.merge()` in our 
code (especially tests!). 
   
   The `session.merge()` function operates strictly on primary keys as 
mentioned in [this SQLAlchemy 
docs](https://docs.sqlalchemy.org/en/20/orm/session_state_management.html#merging),
 which means it no longer recognizes the unique constraint on `["dag_id", 
"task_id", "run_id", "map_index"]` to identify existing `TaskInstance` records. 
This leads to issues in cases where `session.merge()` was previously used to 
either update or insert TaskInstance records, as it now fails to locate the 
intended record by the unique constraint.
   
   Example:
   
   
https://github.com/apache/airflow/blob/b2ecb6c9caacd2ca7a2c1519ca892b19b2bb35fb/tests/models/test_dag.py#L2013-L2026
   


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