From da1af3d8b01ac6928447593f055d6476bbbc03f4 Mon Sep 17 00:00:00 2001 From: Guy Marriott Date: Wed, 17 Apr 2019 15:15:17 +1200 Subject: [PATCH] FIX Postgres booleans should return as int for consistency --- src/ORM/Connect/PDOStatementHandle.php | 1 + tests/php/ORM/DatabaseTest.php | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/ORM/Connect/PDOStatementHandle.php b/src/ORM/Connect/PDOStatementHandle.php index 259e71091..4eae21fef 100644 --- a/src/ORM/Connect/PDOStatementHandle.php +++ b/src/ORM/Connect/PDOStatementHandle.php @@ -47,6 +47,7 @@ class PDOStatementHandle 'float8' => 'float', 'float16' => 'float', 'numeric' => 'float', + 'bool' => 'int', // Bools should be ints // MySQL 'NEWDECIMAL' => 'float', diff --git a/tests/php/ORM/DatabaseTest.php b/tests/php/ORM/DatabaseTest.php index a13ff7d97..babcdb402 100644 --- a/tests/php/ORM/DatabaseTest.php +++ b/tests/php/ORM/DatabaseTest.php @@ -267,5 +267,9 @@ class DatabaseTest extends SapphireTest // Dates are returned as strings $this->assertInternalType('string', $record['Created'], 'DBDatetime fields should be string (non-prepared)'); + + // Booleans selected directly are ints + $result = DB::query('SELECT TRUE')->first(); + $this->assertInternalType('int', reset($result)); } }