Skip to content

Conversation

malarzm
Copy link
Member

@malarzm malarzm commented Feb 23, 2020

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.

@malarzm malarzm force-pushed the gh-8031-extending-embeddable branch from 526553e to f3402cd Compare February 23, 2020 11:42
Copy link
Member

@beberlei beberlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay! Good catch

// Evaluate annotations on properties/fields
/* @var $property \ReflectionProperty */
foreach ($class->getProperties() as $property) {
if ($metadata->isMappedSuperclass && ! $property->isPrivate()
Copy link
Member

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 :-)

{
foreach ($parentClass->fieldMappings as $mapping) {
if ( ! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass) {
if ( ! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass && ! $parentClass->isEmbeddedClass) {
Copy link
Member

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.

@beberlei beberlei changed the title Test case for #8031 Fix inherited embeddables and nesting after AnnotationDriver change #8006 Mar 1, 2020
@lcobucci
Copy link
Member

lcobucci commented Mar 2, 2020

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.

@beberlei
Copy link
Member

beberlei commented Mar 2, 2020

@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.

@lcobucci
Copy link
Member

lcobucci commented Mar 2, 2020

It wasn't possible before (as far as I remember)

@malarzm
Copy link
Member Author

malarzm commented Mar 2, 2020

I confirm using references wasn't possible as I was really sad when I found out ;)

@lcobucci
Copy link
Member

lcobucci commented Mar 2, 2020

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.

@malarzm
Copy link
Member Author

malarzm commented Mar 2, 2020

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.

I agree, that'd be a new feature anyway

We'd also have to make sure that DQL works properly, btw.

Is this about current patch or still references?

@lcobucci
Copy link
Member

lcobucci commented Mar 2, 2020

References 😁

@beberlei
Copy link
Member

beberlei commented Mar 2, 2020

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.

@beberlei
Copy link
Member

beberlei commented Mar 2, 2020

Added this issue to track improvement to schema validator to disallow this: #8052

@beberlei beberlei added this to the 2.7.2 milestone Mar 15, 2020
@beberlei beberlei merged commit a9b6b72 into 2.7 Mar 15, 2020
@beberlei beberlei deleted the gh-8031-extending-embeddable branch March 15, 2020 00:01
beberlei added a commit to beberlei/doctrine2 that referenced this pull request May 12, 2020
beberlei added a commit that referenced this pull request May 12, 2020
* Revert "Fix inherited embeddables and nesting after AnnotationDriver change #8006 (#8036)"

This reverts commit a9b6b72.

* Revert "Make Embeddable not transient"

This reverts commit 58677c2.

* Housekeeping: CS fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants