Problem on update of nullable boolean field on postgresql #7427

Closed
opened 2026-01-22 15:51:36 +01:00 by admin · 2 comments
Owner

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.

Q A
BC Break no
Version 2.13.5, 3.x (All versions)

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.

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. | Q | A |------------ | ------ | BC Break | no | Version | 2.13.5, 3.x (All versions) #### 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.
admin closed this issue 2026-01-22 15:51:36 +01:00
Author
Owner

@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): 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.
Author
Owner

@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!

@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!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7427