From a5c079160fafcb9349cccb6c434d02ccd52df351 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Sun, 14 Nov 2021 21:55:19 +0900 Subject: [PATCH] setAttribute PDO::ATTR_STRINGIFY_FETCHES, true in php <= 8 id is a string, in php >= 8.1 it is a int https://github.com/php/php-src/blob/PHP-8.1/UPGRADING#L131 --- tests/Iso8601FormatModuleTest.php | 2 ++ tests/SqlQueryModuleTest.php | 3 +++ tests/SqlQueryTest.php | 1 + 3 files changed, 6 insertions(+) diff --git a/tests/Iso8601FormatModuleTest.php b/tests/Iso8601FormatModuleTest.php index 24c1e74..bd69d4c 100644 --- a/tests/Iso8601FormatModuleTest.php +++ b/tests/Iso8601FormatModuleTest.php @@ -6,6 +6,7 @@ use Aura\Sql\ExtendedPdo; use Aura\Sql\ExtendedPdoInterface; +use PDO; use PHPUnit\Framework\TestCase; use Ray\Di\AbstractModule; use Ray\Di\Injector; @@ -21,6 +22,7 @@ class Iso8601FormatModuleTest extends TestCase protected function setUp(): void { $pdo = new ExtendedPdo('sqlite::memory:'); + $pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); $pdo->query('CREATE TABLE IF NOT EXISTS todo ( id INTEGER, title TEXT, diff --git a/tests/SqlQueryModuleTest.php b/tests/SqlQueryModuleTest.php index 9e15ddd..15d8d1a 100644 --- a/tests/SqlQueryModuleTest.php +++ b/tests/SqlQueryModuleTest.php @@ -26,6 +26,8 @@ class SqlQueryModuleTest extends TestCase protected function setUp(): void { $pdo = new ExtendedPdo('sqlite::memory:'); + $pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); + $pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); $pdo->query('CREATE TABLE IF NOT EXISTS todo ( id INTEGER, title TEXT @@ -168,6 +170,7 @@ public function testResourceObject404(): void public function testDevSqlModule(): void { $pdo = new ExtendedPdo('sqlite::memory:'); + $pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); $pdo->query('CREATE TABLE IF NOT EXISTS todo ( id INTEGER, title TEXT diff --git a/tests/SqlQueryTest.php b/tests/SqlQueryTest.php index 49f7813..8e93965 100644 --- a/tests/SqlQueryTest.php +++ b/tests/SqlQueryTest.php @@ -17,6 +17,7 @@ class SqlQueryTest extends TestCase protected function setUp(): void { $pdo = new ExtendedPdo('sqlite::memory:'); + $pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); $pdo->query('CREATE TABLE IF NOT EXISTS todo ( id INTEGER, title TEXT