When I'm trying to save this document to database using form, odm delete image even it not changed. It leads to problem, because target image does not exist anymore.
After some time of investigation, I found out that while checking for changes, odm compare image document (coming) with old value, which originally proxy document and have only id. So comparison always indicate coming document as changed and odm remove old one.
How to reproduce
Create document for storing image in database. Create ReferenceOne relation with orphanRemoval="true" from other document with to image. Try to save this document without changing image.
I can try to create unit test or code for reproducing this issue, but it needs some time to extract this code from project.
Hello
Bug Report
Summary
I'm storing images in database as files like described here https://github.com/doctrine/mongodb-odm/blob/master/docs/en/reference/storing-files-with-mongogridfs.rst. Also I have additional document, which have
ReferenceOne
relation with this images. Also I havecascade={"persist", "remove"}
andorphanRemoval="true"
on this relation.Current behavior
When I'm trying to save this document to database using form, odm delete image even it not changed. It leads to problem, because target image does not exist anymore.
After some time of investigation, I found out that while checking for changes, odm compare image document (coming) with old value, which originally proxy document and have only id. So comparison always indicate coming document as changed and odm remove old one.
How to reproduce
Create document for storing image in database. Create
ReferenceOne
relation withorphanRemoval="true"
from other document with to image. Try to save this document without changing image.I can try to create unit test or code for reproducing this issue, but it needs some time to extract this code from project.
Expected behavior
Image will stay the same and not deleted.
Thank you in advance