mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Single column hydration returns nothing if first item is false-like #6885
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 @TomaszGasior on GitHub (Dec 7, 2021).
Bug Report
Summary
While working on my open source app I found out that scalar column hydration does not return any value, just empty array, when first element of the results is false-like (null, 0, ''…).
How to reproduce
Do something like this but without
<> NULLand<> '':8a2b4fa0d6/src/Repository/RadioStationRepository.php (L68)Simplified example:
If first item from result set is false-like, empty array is returned.
Expected behavior
I would like to get all values from the column, even something like null, ''.
Adding
false !==to6414ad4cbb/lib/Doctrine/ORM/Internal/Hydration/ScalarColumnHydrator.php (L31)kinda fixes the issue. I don't know whether Doctrine is able to return nativefalsefor DBMS-es supporting it and how to support that case if it's needed.@greg0ire commented on GitHub (Dec 13, 2021):
@bhushan please take a look at this 🙏
@bhushan commented on GitHub (Dec 14, 2021):
@TomaszGasior are you planning to PR fix?
@bhushan commented on GitHub (Dec 16, 2021):
@TomaszGasior https://github.com/doctrine/orm/pull/9255 does this test case makes sense or you meant something else ?
@TomaszGasior commented on GitHub (Dec 16, 2021):
@bhushan Unfortunately I am not able to provide PR for now. I consider change in ScalarColumnHydrator.php as debugging hint, maybe not final solution. Yep, provided test looks good (except for lack of string with zero char about which I added comment in the PR).
@MrMitch commented on GitHub (Apr 15, 2022):
Hi @greg0ire @bhushan @TomaszGasior. Thank you for you work on this. I've opened PR #9663 to fix this issue. It includes a test and the fix. Let me know if there is anything else I can do to help.