Skip to content

Conversation

ribeiropaulor
Copy link

Q A
Type bug/feature/improvement
Fixed issues #7022

Summary

PostgreSQL allows 3 values in a boolean column: TRUE, FALSE and NULL.

Previously, when binding NULL to a boolean column, it passed the value as FALSE to the database. It prevents having NULL values in the nullable boolean column.

This PR involves the changes below.

  • It fixes this issue by forwarding NULL to the database.
  • The test has been modified to guarantee correct behavior in this scenario.

PostgreSQL allows 3 values in a boolean column: TRUE, FALSE and NULL.

Previously, when binding `NULL` to a boolean column, it passed the value
as FALSE to the database. It prevents having NULL values in the column,
when using Doctrine DBAL.

It fixes this issue passing `NULL` forward to the database.

The test has been modified to test this scenario.
@ribeiropaulor
Copy link
Author

I have no idea why it CI Testing PHP 7.4 with SQLite failing. I tested in my dev machine and test passed.

What should I do to make it through?

@derrabus
Copy link
Member

I have no idea why it CI Testing PHP 7.4 with SQLite failing.

You're asserting that the database will return a real boolean. However, many databases don't know what a boolean is and even if they do, the corresponding drivers don't cast to boolean. You'll get 0 or 1 instead, either as integer or string.

@VincentLanglet
Copy link
Contributor

@ribeiropaulor did you try removing

assert($valueFromDatabase === null || is_bool($valueFromDatabase));

?

The correct assertion is done by

self::assertSame(
            $input,
            $this->connection->convertToPHPValue($valueFromDatabase, 'boolean'),
            'Must return from database the same value inserted.',
        );

@derrabus
Copy link
Member

Closing in favor of #7059. Thank you for bringing this issue to our attention!

@derrabus derrabus closed this Jul 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants