[DDC-1410] leftJoin with condition WITH & Object Hydratation problem. Created: 10/Oct/11 Updated: 07/Jun/12 Resolved: 28/Oct/11 |
|
| Status: | Resolved |
| Project: | Doctrine 2 - ORM |
| Component/s: | DQL, ORM |
| Affects Version/s: | Git Master |
| Fix Version/s: | 2.1.3 |
| Security Level: | All |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Thomas Tourlourat - Armetiz | Assignee: | Benjamin Eberlei |
| Resolution: | Fixed | Votes: | 2 |
| Labels: | None | ||
| Environment: |
Debian 5 dotdeb |
||
| Attachments: |
|
| Description |
|
Here an example of a simple QueryBuilder : $queryBuilder = $entityManager->createQueryBuilder(); OptionA & OptionB & OptionC three entities.
I have test on OneToMany configuration and I have not problem. The problem only appear with ManyToMany relationships. The problem seems to be on hydratation. The data return on SQL command seems to be correct. |
| Comments |
| Comment by Thomas Tourlourat - Armetiz [ 20/Oct/11 ] |
|
I have made some other search about it. On the queryBuilder described above, I was using getSingleResult / getResult. Here the scalar result : array(3) {
[0]=>
array(21) {
["player_id"]=>
int(2)
["options_id"]=>
NULL
["options_enabled"]=>
NULL
}
[1]=>
array(21) {
["player_id"]=>
int(2)
["options_id"]=>
int(2)
["options_enabled"]=>
bool(true)
}
[2]=>
array(21) {
["player_id"]=>
int(2)
["options_id"]=>
int(4)
["options_enabled"]=>
bool(true)
}
}
Do you have any clue ? |
| Comment by Thomas Tourlourat - Armetiz [ 20/Oct/11 ] |
|
I think I have find the problem. See patch. In the 2.1.2 version, If the first related object wasn't a "nonemptyComponents", the ObjectHydrator initialized the collection by a specific way. |
| Comment by Thomas Tourlourat - Armetiz [ 20/Oct/11 ] |
|
It's a patch for Doctrine/ORM/Internal/Hydration/ObjectHydrator.php version 2.1.2. |
| Comment by Thomas Tourlourat - Armetiz [ 20/Oct/11 ] |
|
I have add a correction on Github : https://github.com/armetiz/doctrine2/commit/42d507632fd27a23220c38bb867b611c3caaab8e |
| Comment by Benjamin Eberlei [ 25/Oct/11 ] |
|
Thanks for digging into that, I will evaluate this issue |
| Comment by Thomas Tourlourat - Armetiz [ 25/Oct/11 ] |
|
No problem, It was blocking for me. To be sure, the best will be to create a new test, but I'm not really familiar to create ORM test case.. Thomas. |
| Comment by Benjamin Eberlei [ 25/Oct/11 ] |
|
can you post your mappings? |
| Comment by Thomas Tourlourat - Armetiz [ 26/Oct/11 ] |
|
PlayerEntity : <?xml version="1.0" encoding="UTF-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> <entity name="PlayerEntity"> <many-to-many field="options" target-entity="OptionEntity" mapped-by="players" /> </entity> </doctrine-mapping> {/code} <?xml version="1.0" encoding="UTF-8"?> I have post all the mapping, but it's Doctrine compliant. Do you need this mapping to create tests ? Do you need any else ? Thomas. |
| Comment by Benjamin Eberlei [ 28/Oct/11 ] |
|
Fixed. |
| Comment by Benjamin Eberlei [ 08/Nov/11 ] |
|
This issue is referenced in Github Pull-Request GH-161 |
| Comment by Benjamin Eberlei [ 07/Jun/12 ] |
|
A related Github Pull-Request [GH-161] was opened |
| Comment by Benjamin Eberlei [ 07/Jun/12 ] |
|
A related Github Pull-Request [GH-161] was closed |