-
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
[Docs] Nullable Embeddables Hydration section #11586
base: 3.2.x
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing this, here are a few fixes.
docs/en/tutorials/embeddables.rst
Outdated
<?php | ||
|
||
#[Entity] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please import the Attributes in this code examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed 5b6bd6f
@SenseException
Is this right?
Would it be good to fix other examples in this file?
Please kindly squash your commits together. If you don't, we'll try to remember to do it for you but it's best if you save us this trouble. How to do that?
|
7c604a2
to
513da5c
Compare
I'm trying to wrap my head around what's happening here. My understanding of embeddables is that we always hydrate them. Having this section elaborate on "nullable embeddables" feels weird because that concept does not exist in the ORM. This section merely documents a weird workaround. I'm not sold that we should document that workaround, but if we do, we should first document the limitation that we attempt to work around before we document the actual workaround. |
Thanks you for your comment.
There is the above description in initializing embeddables section. We should document a difference between a instantiated entity object and a hydrated entity object. |
If you manually construct the object, of course any structure is possible. It's your object, you've created it, you've populated all properties and the ORM is not even aware of its existence. But the ORM will never hydrate This btw applies the same way to any mapped property. For instance, a one-to-many association is hydrated as a collection. We could add a section about "nullable collections" because it's in theory possible to construct an object where the property that's supposed to hold the collection is
If you find a nice way to do that, please go ahead. |
So, Is It like a bug that ORM accepts to flush a entity has a null value instead of the embedded object In Doctrine 3.2.x? |
I wouldn't call it that. The ORM tries to handle this situation gracefully instead of raising an exception. Do you think we should be more strict here? |
Sidenote: If this behavior isn't covered by tests yet, it would need one in case that the nullable embeddables concept will be officially supported and maintained. |
Yes. |
Hi.
I faced to problem #4568. However, I could not find this issue quickly and I was confused...
The behavior should be documented in doctrine tutorial. It will be more kindness.