diff --git a/tests/TestCase/Database/QueryTest.php b/tests/TestCase/Database/QueryTest.php index 6015a920693..3bd2724576b 100644 --- a/tests/TestCase/Database/QueryTest.php +++ b/tests/TestCase/Database/QueryTest.php @@ -2736,6 +2736,12 @@ public function testSqlCaseStatement() { ->add(['published' => 'N']), 1, 'integer' ); + //Postgres requires the case statement to be cast to a integer + if ($this->connection->driver() instanceof \Cake\Database\Driver\Postgres) { + $publishedCase = $query->func()->cast([$publishedCase, 'integer' => 'literal'])->type(' AS '); + $notPublishedCase = $query->func()->cast([$notPublishedCase, 'integer' => 'literal'])->type(' AS '); + } + $results = $query ->select([ 'published' => $query->func()->sum($publishedCase),