diff --git a/src/Support/TypeCaster.php b/src/Support/TypeCaster.php index d939d21..19eddf0 100644 --- a/src/Support/TypeCaster.php +++ b/src/Support/TypeCaster.php @@ -116,6 +116,12 @@ final class TypeCaster return $value->format('Y-m-d H:i:s'); } + // PDO with ATTR_EMULATE_PREPARES = false sends a native bool as an empty string, which a + // TINYINT rejects with "Incorrect integer value: ''". Boolean columns are always 0/1. + if (is_bool($value)) { + return $value ? 1 : 0; + } + return $value; } diff --git a/tests/Unit/Support/TypeCasterDatabaseValueTest.php b/tests/Unit/Support/TypeCasterDatabaseValueTest.php new file mode 100644 index 0000000..de92af2 --- /dev/null +++ b/tests/Unit/Support/TypeCasterDatabaseValueTest.php @@ -0,0 +1,33 @@ +