[DDC-2953] ArrayHydrator: Not all items hydrated while orderBy Created: 05/Feb/14  Updated: 18/Aug/14

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.3.4, 2.4.1
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Mariusz Jaskółka Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 0
Labels: array, hydration
Environment:

Linux and Windows, PHP5


Attachments: File ArrayHydrator.php     File Array_Hydrator_4.2.php     File Array_hydrator_4.2_bugfix.php    
Issue Links:
Dependency
depends on DDC-2955 [GH-933] [WIP] DDC-2953 Resolved

 Description   

I will explain the problem using example and pseudo-code:

I have query like that:
SELECT (...) FROM order LEFT JOIN person LEFT JOIN identifier (...) order by (...)

The rows returned by query are following (the order is very important):
order_id|person_id|identifier_id|
12 |21 |33 |
12 |21 |34 |
11 |21 |35 |
11 |21 |33 |
11 |21 |34 |
12 |21 |35 |

After hydration the result is like:
result[0][person][identifier][0][id]=33
result[0][person][identifier][0][id]=34
result[1][person][identifier][0][id]=35
result[1][person][identifier][0][id]=34

But it should be:
result[0][person][identifier][0][id]=33
result[0][person][identifier][0][id]=34
result[0][person][identifier][0][id]=35
result[1][person][identifier][0][id]=35
result[1][person][identifier][0][id]=34
result[1][person][identifier][0][id]=33

The reason is that ArrayHydrator::_identifierMap contains only object id and parents object id. In may example there is difference in parents parent (grandparent) id.



 Comments   
Comment by Marco Pivetta [ 05/Feb/14 ]

I've started work on this at https://github.com/doctrine/doctrine2/pull/933

Comment by Mariusz Jaskółka [ 06/Feb/14 ]

This is how I temporary solved the issue, maybe it can help (attachment).

Comment by Marco Pivetta [ 06/Feb/14 ]

Mariusz Jaskółka can you provide a diff with current master? This seems to be based off 2.3 or previous versions...

Comment by Mariusz Jaskółka [ 06/Feb/14 ]

Version 2.4.2 oryginal file and bugfix

Comment by Mariusz Jaskółka [ 06/Feb/14 ]

Oh sorry it is version 2.4.1 (composer downloaded that version for me).
I hope it will be ok.

Comment by Marco Pivetta [ 06/Feb/14 ]

Mariusz Jaskółka thanks! I'm trying it right now

Comment by Mariusz Jaskółka [ 06/Feb/14 ]

I added one dimention to $this->_identifierMap to be sure that all object's children's keys will be mapped separately.

Comment by Marco Pivetta [ 06/Feb/14 ]

Mariusz Jaskółka, I've applied your hotfix at https://github.com/doctrine/doctrine2/commit/c05921032ff6947daca2d7275031e5cde4700634 and the tests seem to pass on my system and on travis. You may want to check it out and see if it works for your use case.

Comment by Mariusz Jaskółka [ 06/Feb/14 ]

It works for my use case correctly. You apparently forgot to remove/comment line 82 which is not necessary now.

Comment by Marco Pivetta [ 06/Feb/14 ]

Mariusz Jaskółka fixed, thanks!

Comment by Marco Pivetta [ 14/Jul/14 ]

I don't think we'll have a fix for this issue for 2.5, as it will probably require a complete rewrite of the array hydrator

Comment by Guilherme Blanco [ 14/Jul/14 ]

... and introducing BC breaks.

Comment by Doctrine Bot [ 18/Aug/14 ]

A related Github Pull-Request [GH-933] was closed:
https://github.com/doctrine/doctrine2/pull/933





[DDC-2021] Array Data in Member OF Created: 09/Sep/12  Updated: 11/Jul/14  Resolved: 11/Jul/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.2.3
Fix Version/s: 2.5
Security Level: All

Type: New Feature Priority: Major
Reporter: vahid sohrabloo Assignee: Marco Pivetta
Resolution: Fixed Votes: 1
Labels: array, dql

Issue Links:
Reference
is referenced by DDC-3210 [GH-1080] possible fix for DDC-2021 Resolved

 Description   

Hi.
First sorry for my bad english.
In
SELECT u.id FROM CmsUser u WHERE :groupId MEMBER OF u.groups
DQL we can't use Array of groupId like



 Comments   
Comment by Daniel Sippel [ 09/Jul/14 ]

+1

Simple solution could be this: use SQL IN(value) always instead of the equality sign..

Current situation:
500 Internal Server Error - DBALException
1 linked Exception: PDOException »

An exception occurred while executing 'SELECT w0_.id AS id0, w0_.userId AS userId1, w0_.profileName AS profileName2, w0_.url AS url3, w0_.companyName AS companyName4, w0_.firstName AS firstName5, w0_.lastName AS lastName6, w0_.street AS street7, w0_.houseNo AS houseNo8, w0_.postcode AS postcode9, w0_.city AS city10, w0_.phoneNo AS phoneNo11, w0_.faxNo AS faxNo12, w0_.email AS email13, w0_.websiteUrl AS websiteUrl14, w0_.description AS description15, w0_.created AS created16, w0_.updated AS updated17, w0_.offersFurther AS offersFurther18, w0_.companyLogoImageFileExtension AS companyLogoImageFileExtension19, w0_.location AS location20 FROM profile w0_ WHERE 1 = 1 AND (GLength(LineString(w0_.location, GeomFromText(?)))*100 < 30) AND EXISTS (SELECT 1 FROM profile_attribute_mapping p1_ INNER JOIN profile_attribute w2_ ON p1_.profileattribute_id = w2_.id WHERE p1_.profile_id = w0_.id AND w2_.id = ?, ?)' with params [{}, 1, 2]:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 2)' at line 1
Comment by Daniel Sippel [ 09/Jul/14 ]

pull request https://github.com/doctrine/doctrine2/pull/1080

Solution: use SQL IN(value) always instead of the equality sign

Comment by Doctrine Bot [ 11/Jul/14 ]

A related Github Pull-Request [GH-1080] was closed:
https://github.com/doctrine/doctrine2/pull/1080

Comment by Marco Pivetta [ 11/Jul/14 ]

Handled in DDC-3210, see https://github.com/doctrine/doctrine2/commit/ae0ee724252b8aaf41be9b397d3db3375767095d





Generated at Thu Aug 28 15:23:26 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.