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

Bidirectional one-to-one relations with multiple join columns break in DQL queries #7579

Open
Ma27 opened this issue Jan 23, 2019 · 0 comments

Comments

@Ma27
Copy link
Contributor

Ma27 commented Jan 23, 2019

Bug Report

Q A
BC Break yes
Version 2.6.3 (introduced in 2.6.0)

Summary

DQL queries including bidirectional one-to-one relations break with an exception as BasicEntityPersister#loadOneToOne assumes that such relations consist of a single join column since a360da5 as ClassMetadataInfo#getFieldForColumn breaks if an association mapping has more than one column.

Current behavior

Queries as shown in my failing testcase fail with the following exception on 2.6:

Doctrine\ORM\Mapping\MappingException: Cannot find a field on 'Doctrine\Tests\Functional\OneToOneReference' that is mapped to column 'objectId'. Either the field does not exist or an association exists but it has multiple join columns.

/home/ma27/Projects/orm/lib/Doctrine/ORM/Mapping/MappingException.php:621
/home/ma27/Projects/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php:2961
/home/ma27/Projects/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:805
/home/ma27/Projects/orm/lib/Doctrine/ORM/UnitOfWork.php:2708
/home/ma27/Projects/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php:271
/home/ma27/Projects/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php:492
/home/ma27/Projects/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php:162
/home/ma27/Projects/orm/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php:152
/home/ma27/Projects/orm/lib/Doctrine/ORM/AbstractQuery.php:976
/home/ma27/Projects/orm/lib/Doctrine/ORM/AbstractQuery.php:922
/home/ma27/Projects/orm/lib/Doctrine/ORM/AbstractQuery.php:726
/home/ma27/Projects/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneWithMultipleJoinColumnsTest.php:43

How to reproduce

I created a failing testcase in my fork which passes on 2.5, but fails on 2.6.

I didn't test it on master as it misses the method Doctrine\ORM\Persisters\Entity\BasicEntityPersister#loadOneToOneEntity. I assume that 3.0/master is too far diverged from 2.6, so a reproduction on master will be way harder.

Expected behavior

That the $qb->getQuery()->getResult() (see my example) resolves to an entity and doesn't break with an exception.

tomudding added a commit to GEWIS/orm that referenced this issue Jun 28, 2021
This reverts a small change to Doctrine\ORM\Persisters\Entity\BasicEntityPersister
which caused one-to-one relations with an @JoinColumns annotation to break.

See doctrine#7579 for more information.
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

1 participant