mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Array hydrator returns null values instead of actual elements in one-to-many relationships #6873
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @LinasRam on GitHub (Nov 11, 2021).
Bug Report
Summary
The issue is associated with DBMS (MariaDB, in my case) returning same joined rows in different order for separate parent rows. When row ordering is 'random', it may cause
ArrayHydratormapping problems, which results in null values in nested arrays of one-to-many relationships. Check the "Current behavior" section, it will be easier to understand by example.Current behavior
Assume that we have a result set of these rows:
We fetch two articles, which belong to the same user and also join user's phone numbers. The key point is that for second article rows, phone numbers are in different order than they were for the first one.
Array hydrated results of such dataset will return:
As you can see, in the second article there is a
nullphone number and it is a bug.How to reproduce
Added a pull request with a unit test and a possible solution to this bug: #9186
Expected behavior
The expected result of my provided example should look like this: