Possible relationship mixup #6410

Closed
opened 2026-01-22 15:32:47 +01:00 by admin · 1 comment
Owner

Originally created by @dompie on GitHub (Feb 25, 2020).

Bug Report

Q A
BC Break don't know
Version 2.7.1

Summary

Two bidirectional OneToMany relationships are mixed up after loading the the entity from the inverse side.

Current behavior

Create three Company objects.
Set Company2 and Company3 as Suppliers for Company1 in a bidirectional OneToMany relationship.
Leave customers for Company1 empty.
Flush && Clear
Load Company1 and see that it has relationship to 2 Customers and no Suppliers .

Seel https://github.com/dompie/doctrine-issue for more details and showcase.

~~~ Pre persist Company states ~~~
Compy 1 amount suppliers: 2 (expecting 2)
Compy 1 amount customers: 0 (expecting 0)
Suppy 1 amount customers: 1 (expecting 1)
Suppy 1 amount suppliers: 0 (expecting 0)
Suppy 2 amount customers: 1 (expecting 1)
Suppy 2 amount suppliers: 0 (expecting 0)

//flush && clear

~~~ Loaded CustomerSupplierRelation states ~~~
customer | supplier
Compy 1  | Suppy 1 
Compy 1  | Suppy 2 

//flush && clear

! [NOTE] ~~~ Loaded Company state ~~~                                                         
Compy 1 amount suppliers: 0 (expecting 2)
Compy 1 amount customers: 2 (expecting 0)
Suppy 1 amount customers: 0 (expecting 1)
Suppy 1 amount suppliers: 1 (expecting 0)
Suppy 2 amount customers: 0 (expecting 1)
Suppy 2 amount suppliers: 1 (expecting 0)

How to reproduce

See for Entities: https://github.com/dompie/doctrine-issue/tree/master/src/Entity for the entities.
See for app: https://github.com/dompie/doctrine-issue/blob/master/src/Command/RunCommand.php

Expected behavior

When calling Company->getSuppliers(), the previously added CustomerSupplierRelations should be returned there instead of on Company->getCustomers()

Originally created by @dompie on GitHub (Feb 25, 2020). ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | don't know | Version | 2.7.1 #### Summary Two bidirectional OneToMany relationships are mixed up after loading the the entity from the inverse side. #### Current behavior Create three Company objects. Set Company2 and Company3 as Suppliers for Company1 in a bidirectional OneToMany relationship. Leave customers for Company1 empty. Flush && Clear Load Company1 and see that it has relationship to 2 Customers and no Suppliers . Seel https://github.com/dompie/doctrine-issue for more details and showcase. ``` ~~~ Pre persist Company states ~~~ Compy 1 amount suppliers: 2 (expecting 2) Compy 1 amount customers: 0 (expecting 0) Suppy 1 amount customers: 1 (expecting 1) Suppy 1 amount suppliers: 0 (expecting 0) Suppy 2 amount customers: 1 (expecting 1) Suppy 2 amount suppliers: 0 (expecting 0) //flush && clear ~~~ Loaded CustomerSupplierRelation states ~~~ customer | supplier Compy 1 | Suppy 1 Compy 1 | Suppy 2 //flush && clear ! [NOTE] ~~~ Loaded Company state ~~~ Compy 1 amount suppliers: 0 (expecting 2) Compy 1 amount customers: 2 (expecting 0) Suppy 1 amount customers: 0 (expecting 1) Suppy 1 amount suppliers: 1 (expecting 0) Suppy 2 amount customers: 0 (expecting 1) Suppy 2 amount suppliers: 1 (expecting 0) ``` #### How to reproduce See for Entities: https://github.com/dompie/doctrine-issue/tree/master/src/Entity for the entities. See for app: https://github.com/dompie/doctrine-issue/blob/master/src/Command/RunCommand.php #### Expected behavior When calling `Company->getSuppliers()`, the previously added CustomerSupplierRelations should be returned there instead of on `Company->getCustomers()`
admin closed this issue 2026-01-22 15:32:47 +01:00
Author
Owner

@dompie commented on GitHub (Feb 28, 2020):

Issue solved, not a bug.

@dompie commented on GitHub (Feb 28, 2020): Issue solved, not a bug.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6410