mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Problem on update of nullable boolean field on postgresql #7427
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 @fghamsary on GitHub (Oct 2, 2024).
Bug Report
If you want to update a nullable boolean field to set it to null, the result in postgresql will always be false.
The problem is the ParameterType::BOOLEAN will force the value null to false when update is done.
Summary
It's quiet simple create an simple entity containing nullable boolean field, set it to true, save and flush it.
Afterwards get the same entity and set the value to null, after flush you will have false in database!
Current behavior
Null is forced to false in update query when using postgresql. (Don't know if other databases have the same issue)
How to reproduce
It's quiet simple create an simple entity containing nullable boolean field, set it to true, save and flush it.
Afterwards get the same entity and set the value to null, after flush you will have false in database!
I will resolve the issue myself with a pull request. The fix is quiet simple.
Expected behavior
The value which should be persisted on database should be null.
@fghamsary commented on GitHub (Oct 2, 2024):
After some more investigation, it's not really for the orm project but dbal project, so I'll create the same ticket on that project and resolve it there.
@fghamsary commented on GitHub (Oct 2, 2024):
This bug have already been reported: https://github.com/doctrine/dbal/issues/2580
But apparently instead of correcting the bug, they just ignored it and said that it's a problem on PDO side.
This is not correct at all, PDO already has ParameterType::NULL which can be used!