DDC-2953: ArrayHydrator: Not all items hydrated while orderBy #3716

Open
doctrinebot opened this Issue Feb 5, 2014 · 14 comments

2 participants

@doctrinebot

Jira issue originally created by user mariusz.jaskolka:

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):
orderid|person_id|identifierid|
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.

@doctrinebot

Comment created by @ocramius:

I've started work on this at #933

@doctrinebot

Comment created by mariusz.jaskolka:

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

@doctrinebot

Comment created by @ocramius:

[~mariusz.jaskolka] can you provide a diff with current master? This seems to be based off 2.3 or previous versions...

@doctrinebot

Comment created by mariusz.jaskolka:

Version 2.4.2 oryginal file and bugfix

@doctrinebot

Comment created by mariusz.jaskolka:

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

@doctrinebot

Comment created by @ocramius:

[~mariusz.jaskolka] thanks! I'm trying it right now

@doctrinebot

Comment created by mariusz.jaskolka:

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

@doctrinebot

Comment created by @ocramius:

[~mariusz.jaskolka], I've applied your hotfix at c059210 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.

@doctrinebot

Comment created by mariusz.jaskolka:

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

@doctrinebot

Comment created by @ocramius:

[~mariusz.jaskolka] fixed, thanks!

@doctrinebot

Comment created by @ocramius:

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

@doctrinebot

Comment created by @guilhermeblanco:

... and introducing BC breaks.

@doctrinebot

Comment created by @doctrinebot:

A related Github Pull-Request [GH-933] was closed:
#933

@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment