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
Entity relations are not serialized properly when calling toJSON
on flushed entities after being created with EntityRepository.create
#784
Comments
This is actually quite huge breaking change, so will make this hidden behind a config toggle, keeping the default behaviour as is. |
In |
Sounds good, thank you for implementing it! ✌️ |
@B4nan I just stumbled across this issue after commenting on #1861 (comment). I have |
No idea, provide a reproduction if you need help, as you might be facing some other problem (and yes, |
The default will change to true in v5 |
Related: #784 BREAKING CHANGE: After flushing a new entity, all relations are marked as populated, just like if the entity was loaded from the db. This aligns the serialized output of `e.toJSON()` of a loaded entity and just-inserted one. In v4 this behaviour was disabled by default, so even after the new entity was flushed, the serialized form contained only FKs for its relations. We can opt in to this old behaviour via `populateAfterFlush: false`.
Describe the bug
When using
toJSON
on an Entity after it is being created, persisted and flushed via thecreate
andpersistAndFlush
methods on the specific repository, its related entities are not being serialized properly. Instead of getting the result oftoJSON
being called on them we get a number representing their id.Stack trace
To Reproduce
See above.
Expected behavior
I'm expecting for the
articleEntity.toJSON()
to returnwithout the need of calling
findOne
after flushing.Additional context
Versions
The text was updated successfully, but these errors were encountered: