Bug #81002 [NEW]: Booleans are cast to integers when inserting records
From: jeroen dot vanoort at webparking dot nl
Operating system: Alpine
PHP version: 8.0.5
Package: PDO PgSQL
Bug Type: Bug
Bug description:Booleans are cast to integers when inserting records
Description:
------------
It seems that, since using 8.0.5, booleans are cast to integers when
inserting records into a PostgreSQL database table. This causes
PostgreSQL to throw an exception.
I use Laravel to do this, so it's not trivial for me to create a test
script that's only PHP. However, I did want to report this as it seems
to be an unintentional breaking change.
How did I determine this isn't related to Laravel or PostgreSQL?
I tested my project with the php:8.0.3-fpm-alpine and
php:8.0.3-fpm-alpine docker images. 8.0.3 works fine, 8.0.5 gives me the
error below. I did not change the Laravel version, nor did I change the
PostgreSQL version.
The boolean true seems to have been casted to an integer in the SQL
shown in the error message.
Test script:
---------------
ProductCategory::create([
'name' => 'FooBar',
'is_active' => true,
]);
ProductCategory is a Laravel model.
Expected result:
----------------
The record is added without errors or warnings.
Actual result:
--------------
Illuminate\Database\QueryException: SQLSTATE[42804]: Datatype mismatch:
7 ERROR: column "is_active" is of type boolean but expression is of
type integer
LINE 1: ...e", "id", "updated_at", "created_at") values ($1, $2,
$3,
$4...
^
HINT: You will need to rewrite or cast the expression. (SQL: insert
into "product_categories" ("name", "is_active", "id",
"updated_at",
"created_at") values (FooBar, 1, 1eba993a-28f3-6596-9455-7e5293aad700,
2021-04-30 11:08:31, 2021-04-30 11:08:31))
--
Edit bug report at https://bugs.php.net/bug.php?id=81002&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81002&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81002&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81002&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81002&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81002&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81002&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81002&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81002&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81002&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81002&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81002&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81002&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81002&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81002&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81002&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81002&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81002&r=mysqlcfg
Thread (7 messages)
- jeroen dot vanoort at webparking dot nl