Closed obstschale closed 3 years ago
I just found this commit https://github.com/fzaninotto/Faker/commit/5337ce5261b393937bd7aaebb21020159756a152 related to https://github.com/fzaninotto/Faker/issues/1862. This should fix my issue, when a new version is available. Hence I close this issue.
Summary
I have 2 entitys. They have a ManyToOne relationship. When I seed the DB I get an error, that the entity manager thinks there are non-persisted entities.
Versions
fzaninotto/faker
Self-enclosed code snippet for reproduction
Expected output
Actual output
Explanation
In
Doctrine\Populator::execute()
Line105
the entity manager is cleaned after each entity class. That means, the populator persistsAccountType
and that works. But now it cleans the entity manager before creating and persistingAccountClasses
. The Populator uses the before insertedAccountTypes
correctly, but the entity manage does not know them and thinks they are not persisted.Our Doctrine Relationship is not set up to cascade:persist, hence Doctrine does not persist (again) the
AccountType
objects and the error is thrown.If I comment line
105
everything works fine.Does anyone know a workaround? Or may I start a PR to handle the cleaning differntly. For example with a flag to clean after everything is persisted.