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

Updating from symfony/doctrine-bridge 4.4.15 to 4.4.16 results in doctrine mapping exception #11970

Closed
tannyl opened this issue Oct 28, 2020 · 3 comments

Comments

@tannyl
Copy link
Contributor

tannyl commented Oct 28, 2020

Sylius version affected: 1.8.2 (most likely others as well)

Description
When updating from symfony/doctrine-bridge 4.4.15 to 4.4.16 this breaks Sylius.
When running bin/console cache:clear after updating to 4.4.16 this results in the followering error:

In MappingException.php line 621:
  Cannot find a field on 'Sylius\Component\Core\Model\ChannelPricing' that is mapped to column 'channelCode'. Either the field does not exi  
  st or an association exists but it has multiple join columns.

I suspect that this is due to the changes to symfony/doctrine-bridge/PropertyInfo/DoctrineExtractor.php as seen her: symfony/doctrine-bridge@v4.4.15...v4.4.16

Steps to reproduce
Update symfony/doctrine-bridge from 4.4.15 to 4.4.16 and run bin/console cache:clear

@tannyl
Copy link
Contributor Author

tannyl commented Oct 28, 2020

To try and temporally fix the problem I added this to our extended ProductVariant

    /**
     * @ORM\OneToMany(targetEntity="Sylius\Component\Core\Model\ChannelPricingInterface", mappedBy="productVariant", orphanRemoval=true, indexBy="channel_code", cascade={"ALL"})
     *
     * @var Collection
     */
    protected $channelPricings;

The indexBy is not changed from "channelCode" to "channel_code", which fixes the above error.

By a new problem arises. The collection that is returned does not use the "channel_code" as key, as it should.

In 4.4.15 it would return this as expected (without the above change to IndexBy ofcourse:
image

But now in 4.4.16 it ignores the indexBy and uses numbers as keys. Which in turn breaks Sylius again, as it never finds any price for any of the variants.
image

Strangely enough if I use "id" in indexBy it works as expected, and they entries in the collection is using the ids as keys.

So I guess symfony/doctrine-bridge 4.4.16 is broken.

@lchrusciel
Copy link
Member

The problem still has to be fixed on Symfony/DoctrineBridge

@lucaball
Copy link

Yes, but it is reported, see symfony/symfony#38861

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