-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DoctrineWriter: fix setting associations #183
base: master
Are you sure you want to change the base?
Conversation
The associations set in loadAssociationObjectsToEntity() method will be overwritten by the original value/foreign key. This will lead to an Doctrine exception, coz Doctrine is expecting an entity object and not a scalar value.
Can you provide a failing test case? |
Sorry, what do you mean? |
Can you provide a short snippet which shows the error, so i can reproduce your issue. |
Sure. I have a target model Store with an association to a model Industry CSV source: Industry Store Here is the Error: Found entity of type on association Shopware\CustomModels\StoreLocator\Store#industry, but expecting Shopware\CustomModels\StoreLocator\Industry in vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php on line 783 And here is the xDebug output. $value should not be "1". It should be an object of type Industry. Actually, all associations were already set in the loadAssociationObjectsToEntity() method, which was called directly before updateEntity() method. So the associations does not have to be set again. |
👍 Fixes #188. |
This might fix your issue but as travis reported it completely break the current workflow. I can't really produce your issue. @webdevilopers Maybe you can submit a PR with an testcase which demostrate the bug. |
As mentioned in #188 (comment) I was wondering why the fix worked. My issue looked more like a reading - not writing - issue in #188. I will try the same import with a new |
Ah okay i think your issue is related to the doctrine entity manager clear behaviour. The This should solve your problem:
|
I'm currently not working on that project but this looks like the main issue, thanks @Baachi . |
A fix is difficult because it depends on your needs. |
The associations set in loadAssociationObjectsToEntity() method will be overwritten by the original value/foreign key. This will lead to an Doctrine exception, coz Doctrine is expecting an entity object and not a scalar value.