Skip to content
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

Embeddable value object is loaded as NULL in 2.7.2 #8089

Closed
vicdelfant opened this issue Apr 1, 2020 · 5 comments
Closed

Embeddable value object is loaded as NULL in 2.7.2 #8089

vicdelfant opened this issue Apr 1, 2020 · 5 comments

Comments

@vicdelfant
Copy link

vicdelfant commented Apr 1, 2020

BC Break Report

Q A
BC Break yes
Version 2.7.2

Summary

We extensively use custom types as value types, such as an InvoiceCode in an Invoice entity (Invoice::$code). In our case, the InvoiceCode is an embeddable. For some reason, these properties are now left as a null value upon loading such an entity from the database.

Previous behavior

In doctrine/orm:2.7.1, Invoice::$code is initialized properly.

Current behavior

In doctrine/orm:2.7.2, Invoice::$code is initialized as null. This makes me think that this may be related to #8031. The diff between 2.7.1 and 2.7.2 does show some changes that involve embeddables, too.

How to reproduce

Upgrade to 2.7.2 and use the following entity and embeddable. The entity and embeddable are trimmed for readability but you get the gist:

Entity

class Invoice
{
    /**
     * @ORM\Embedded(class="FQCN\Foo\Bar\InvoiceCode")
     *
     * @var InvoiceCode
     */
    private $code;
}

Embedded

/**
 * @ORM\Embeddable
 */
class InvoiceCode extends AbstractYearSequenceValue
{
    
}

/**
 * @ORM\Embeddable
 * @ORM\MappedSuperclass
 */
abstract class AbstractYearSequenceValue
{
    /**
     * @ORM\Column(type="integer", name="number", length=6)
     *
     * @var int
     */
    protected $number;

    /**
     * @ORM\Column(type="smallint", name="year", length=4)
     *
     * @var int
     */
    protected $year;
}

Failing test is coming up (will try to squeeze it in today).

@vicdelfant
Copy link
Author

Right, failing test has been added in #8090. I noticed that the @MappedSuperclass annotation on the AbstractYearSequenceValue seems to be the trigger. Without it, things work like they should in 2.7.2. As soon as I add it, the test fails in 2.7.2.

This may actually be an error on my end; I added the MappedSuperclass because of this comment but I simply could have misunderstood the recommendation.

@beberlei
Copy link
Member

beberlei commented Apr 1, 2020

@vicdelfant just to make sure, did you update doctrine/reflection and doctrine/persistence to the latest versions too?

@vicdelfant
Copy link
Author

Not specifically since they're pulled in by symfony/orm-pack, but here is the version info just to be sure:

Failing (ORM 2.7.2)

$ composer info doctrine/orm
name     : doctrine/orm
versions : * v2.7.2

$ composer info doctrine/reflection
name     : doctrine/reflection
versions : * 1.2.1

composer info doctrine/persistence
name     : doctrine/persistence
versions : * 1.3.7

Working (ORM 2.7.1)

$ composer info doctrine/orm
name     : doctrine/orm
versions : * v2.7.1

$ composer info doctrine/reflection
name     : doctrine/reflection
versions : * 1.2.1

$ composer info doctrine/persistence
name     : doctrine/persistence
versions : * 1.3.7

@Qonstrukt
Copy link

Qonstrukt commented May 11, 2020

It seems embeddables with inheritance are broken in more ways since 2.7.2.
I can't even query for properties in the base embeddable class anymore.

In the context of this issue:
I get an Invoice has no field or association named code.number Semantical Error. While properties that I add to InvoiceCode itself are still queryable.

If you want me to open up a separate issue about this, just shout.

@beberlei
Copy link
Member

We will revert all the embeddable changes for the next mini release

@beberlei beberlei closed this as completed Dec 6, 2020
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

No branches or pull requests

3 participants