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
Fix inherited embeddables and nesting after AnnotationDriver change #8006 #8036
Conversation
526553e
to
f3402cd
Compare
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.
Yay! Good catch
@@ -277,6 +277,8 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) | |||
/* @var $property \ReflectionProperty */ | |||
foreach ($class->getProperties() as $property) { | |||
if ($metadata->isMappedSuperclass && ! $property->isPrivate() |
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.
I believe the time has come to move the whole expression of this if condition into a function :-)
@@ -401,7 +401,7 @@ private function getShortName($className) | |||
private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass) | |||
{ | |||
foreach ($parentClass->fieldMappings as $mapping) { | |||
if ( ! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass) { | |||
if ( ! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass && ! $parentClass->isEmbeddedClass) { |
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.
Couldn't you use the isEntity
method here? This function is used during mapping construction time, so its not critical here to avoid too many function calls.
It seems like these changes are treating embeddable objects as mapped superclasses... can we also make sure we don't add support to associations for embeddable? This would be quite odd design-wise since they're value objects. |
@lcobucci I am afraid adding relationships to embeddables was possible before or not? If it was possible before I don't think we should prevent adding associations though, since Doctrine doesn't prescribe a paradigm such as DDD, we don't really have value objects here but embeddables. |
It wasn't possible before (as far as I remember) |
I confirm using references wasn't possible as I was really sad when I found out ;) |
If you want to expand the concept of an embeddable, that's fine. I'd just suggest to avoid, as much as, doing that on a patch release. We'd also have to make sure that DQL works properly, btw. |
I agree, that'd be a new feature anyway
Is this about current patch or still references? |
References 😁 |
There isn't a specific error on 2.7.0 with associations on embedded objects though. They are just not stored. The embeddable has the association, but its not copied over to the Entity. The same is true of 2.7.2 with this patch. So there is nothing we need to change. |
Added this issue to track improvement to schema validator to disallow this: #8052 |
…change doctrine#8006 (doctrine#8036)" This reverts commit a9b6b72.
Changing
AnnotationDriver
to mark embeddables as "entities" in #8006 caused a bunch of bugs with inheritance and nested embeddables that are fixed by this PR.