-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Ignore non-nullable typed property for Embeddable when hydrating #8015
Ignore non-nullable typed property for Embeddable when hydrating #8015
Conversation
ddfd379
to
dbaaf37
Compare
…ed properties in embeddables
dbaaf37
to
dbac210
Compare
@doctrine/doctrinecore Should this PR target the 2.7 branch? |
Since 2.6 is no longer maintained, this indeed needs to target 2.7. |
target updated PS: the CONTRIBUTING.md needs updating :-)
|
Thank you. I guess we could change the link to the documentation page where the supported versions are listed and remove versions from the CONTRIBUTING.md. |
This is the wrong bugfix. The problem is that If you add the following to line 36, it already fails: $this->assertNull($foo->bar); The fix should be that this is already NULL. But thats actually hard to detect, because if all embeddable properities are null, should the embeddable be null? or is the embeddable present? |
Maybe we can even use this, but its actually necessary to check this before line 89: if ($value === null) {
return
} |
@beberlei I totally agree, and think the embeddable should be null, if all embeddable properties are null. But that's not the current behaviour. The current behaviour it to have the embeddable present (with all null values).
Since #4568 ended rather badly... I decided to fix that myself like this with a PostLoad-listener:
I'm not familiar enough with Doctrine's inner workings, and how the same might be achieved in an other way. So if you see a solution, and I might be of any help, let me know! |
This is the PR requested for issue #8014.
Following the explanation in the bug report, when you have a null value in the database (which is valid because the parent property containing the Embeddable can be null, i.e. all the properties o f the Embeddable are null in the database), but the typed property is required (does not allow null), the hydrator should skip setting that null value to the typed property.