mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Set foreign key ids works on update but not on create? #7534
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @fGuix on GitHub (Jul 10, 2025).
Bug Report
Summary
Hi,
I have two DB and I migrate some data from one to the other. The problem is when I migrate the relationship Ids.
Ex.g. : my "Activity" table has a relation with a "Dossier" table through "dossierId"
You can notice that I explicitly added the column dossierId. I use the related setter during my migration to set the ID, easier than manually redefining all relations (but it might be a non-intended way of doing this).
Current behavior
With the exact same source data:
Expected behavior
Either Both operations should save the id or both operations should not save the id ?
I could understand if none of the operations worked and that is a wrong way of doing. But as it works for the update operation, it feels inconsistent with the create operation.
How to reproduce
A manyToOne relationship between two table and the relationship id explicitly declared.
Create an entity with the id specified. -> id not saved
Update an entity with the id specified -> id saved (and thus the relation is set)