Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
php-version: ${{ matrix.php-version }}
extension: ${{ matrix.extension }}
dependency-versions: ${{ matrix.dependency-versions }}
config-file-suffix: ${{ matrix.config-file-suffix }}

strategy:
matrix:
Expand All @@ -57,6 +58,11 @@ jobs:
php-version: "8.4"
dependency-versions: "highest"
extension: "sqlite3"
- os: "ubuntu-22.04"
php-version: "8.2"
dependency-versions: "highest"
extension: "pdo_sqlite"
config-file-suffix: "-stringify_fetches"

phpunit-oracle:
name: "PHPUnit with Oracle"
Expand Down Expand Up @@ -95,6 +101,7 @@ jobs:
postgres-version: ${{ matrix.postgres-version }}
extension: ${{ matrix.extension }}
postgres-locale-provider: ${{ matrix.postgres-locale-provider }}
config-file-suffix: ${{ matrix.config-file-suffix }}

strategy:
matrix:
Expand All @@ -121,6 +128,10 @@ jobs:
postgres-version: "15"
extension: "pdo_pgsql"
postgres-locale-provider: "icu"
- php-version: "8.2"
postgres-version: "17"
extension: "pdo_pgsql"
config-file-suffix: "-stringify_fetches"

phpunit-mariadb:
name: "PHPUnit with MariaDB"
Expand All @@ -130,6 +141,7 @@ jobs:
php-version: ${{ matrix.php-version }}
mariadb-version: ${{ matrix.mariadb-version }}
extension: ${{ matrix.extension }}
config-file-suffix: ${{ matrix.config-file-suffix }}

strategy:
matrix:
Expand All @@ -154,6 +166,10 @@ jobs:
- php-version: "8.2"
mariadb-version: "11.4"
extension: "pdo_mysql"
- config-file-suffix: "-stringify_fetches"
php-version: "8.2"
mariadb-version: "11.4"
extension: "pdo_mysql"

phpunit-mysql:
name: "PHPUnit with MySQL"
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/phpunit-mariadb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
extension:
required: true
type: string
config-file-suffix:
required: false
type: string
default: ''

jobs:
phpunit-mariadb:
Expand Down Expand Up @@ -53,5 +57,5 @@ jobs:
- name: Upload coverage file
uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}-${{ inputs.mariadb-version }}-php-${{ inputs.php-version }}-${{ inputs.extension }}.coverage
name: ${{ github.job }}-${{ inputs.mariadb-version }}-php-${{ inputs.php-version }}-${{ inputs.extension }}${{ inputs.config-file-suffix }}.coverage
path: coverage.xml
8 changes: 6 additions & 2 deletions .github/workflows/phpunit-postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ on:
postgres-locale-provider:
required: true
type: string
config-file-suffix:
required: false
type: string
default: ''

jobs:
phpunit-postgres:
Expand Down Expand Up @@ -51,10 +55,10 @@ jobs:
composer-options: '--ignore-platform-req=php+'

- name: Run PHPUnit
run: vendor/bin/phpunit -c ci/github/phpunit/${{ inputs.extension }}.xml --coverage-clover=coverage.xml
run: vendor/bin/phpunit -c ci/github/phpunit/${{ inputs.extension }}${{ inputs.config-file-suffix }}.xml --coverage-clover=coverage.xml

- name: Upload coverage file
uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}-${{ inputs.postgres-version }}-php-${{ inputs.php-version }}-${{ inputs.extension }}.coverage
name: ${{ github.job }}-${{ inputs.postgres-version }}-php-${{ inputs.php-version }}-${{ inputs.extension }}${{ inputs.config-file-suffix }}.coverage
path: coverage.xml
8 changes: 6 additions & 2 deletions .github/workflows/phpunit-sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ on:
dependency-versions:
required: true
type: string
config-file-suffix:
required: false
type: string
default: ''

jobs:
phpunit-sqlite:
Expand Down Expand Up @@ -50,10 +54,10 @@ jobs:
if: ${{ inputs.extension == 'sqlite3' }}

- name: Run PHPUnit
run: vendor/bin/phpunit -c ci/github/phpunit/${{ inputs.extension }}.xml --coverage-clover=coverage.xml
run: vendor/bin/phpunit -c ci/github/phpunit/${{ inputs.extension }}${{ inputs.config-file-suffix }}.xml --coverage-clover=coverage.xml

- name: Upload coverage file
uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}-php-${{ inputs.php-version }}-${{ inputs.extension }}-${{ inputs.dependency-versions }}.coverage
name: ${{ github.job }}-php-${{ inputs.php-version }}-${{ inputs.extension }}${{ inputs.config-file-suffix }}-${{ inputs.dependency-versions }}.coverage
path: coverage.xml
36 changes: 36 additions & 0 deletions ci/github/phpunit/pdo_pgsql-stringify_fetches.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
failOnRisky="true"
failOnWarning="true"
failOnNotice="true"
failOnPhpunitDeprecation="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
>
<php>
<ini name="error_reporting" value="-1" />

<var name="db_driver" value="pdo_pgsql"/>
<!-- see \PDO::ATTR_STRINGIFY_FETCHES-->
<var name="db_driver_option_17" value="true"/>
<var name="db_host" value="localhost" />
<var name="db_user" value="postgres" />
<var name="db_password" value="postgres" />
<var name="db_dbname" value="doctrine_tests" />
</php>

<testsuites>
<testsuite name="Doctrine DBAL Test Suite">
<directory>../../../tests</directory>
</testsuite>
</testsuites>

<source>
<include>
<directory>../../../src</directory>
</include>
</source>
</phpunit>
33 changes: 33 additions & 0 deletions ci/github/phpunit/pdo_sqlite-stringify_fetches.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
failOnRisky="true"
failOnWarning="true"
failOnNotice="true"
failOnPhpunitDeprecation="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
>
<php>
<ini name="error_reporting" value="-1" />

<var name="db_driver" value="pdo_sqlite"/>
<!-- see \PDO::ATTR_STRINGIFY_FETCHES-->
<var name="db_driver_option_17" value="true"/>
<var name="db_memory" value="true"/>
</php>

<testsuites>
<testsuite name="Doctrine DBAL Test Suite">
<directory>../../../tests</directory>
</testsuite>
</testsuites>

<source>
<include>
<directory>../../../src</directory>
</include>
</source>
</phpunit>
6 changes: 3 additions & 3 deletions src/Schema/PostgreSQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ protected function _getPortableTableForeignKeyDefinition(array $tableForeignKey)
[
'onUpdate' => $onUpdate,
'onDelete' => $onDelete,
'deferrable' => $tableForeignKey['condeferrable'],
'deferred' => $tableForeignKey['condeferred'],
'deferrable' => (bool) $tableForeignKey['condeferrable'],
'deferred' => (bool) $tableForeignKey['condeferred'],
],
);
}
Expand Down Expand Up @@ -170,7 +170,7 @@ static function (array $row): array {
return [
'key_name' => $row['relname'],
'non_unique' => ! $row['indisunique'],
'primary' => $row['indisprimary'],
'primary' => (bool) $row['indisprimary'],
'where' => $row['where'],
'column_name' => $row['attname'],
];
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Driver/DBAL6044Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected function setUp(): void
{
parent::setUp();

if (TestUtil::isDriverOneOf('pdo_pgsql', 'pgsql')) {
if (TestUtil::isDriverOneOf('pdo_pgsql', 'pgsql') && ! TestUtil::isPdoStringifyFetchesEnabled()) {
return;
}

Expand Down
10 changes: 8 additions & 2 deletions tests/Functional/FetchBooleanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@

use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Tests\FunctionalTestCase;
use Doctrine\DBAL\Tests\TestUtil;
use PHPUnit\Framework\Attributes\DataProvider;

class FetchBooleanTest extends FunctionalTestCase
{
protected function setUp(): void
{
if ($this->connection->getDatabasePlatform() instanceof PostgreSQLPlatform) {
if (
$this->connection->getDatabasePlatform() instanceof PostgreSQLPlatform
&& ! TestUtil::isPdoStringifyFetchesEnabled()
) {
return;
}

self::markTestSkipped('Only PostgreSQL supports boolean values natively');
self::markTestSkipped(
'Only PostgreSQL supports boolean values natively, as long as PDO does not stringify them.',
);
}

#[DataProvider('booleanLiteralProvider')]
Expand Down
3 changes: 1 addition & 2 deletions tests/Functional/Query/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
use Doctrine\DBAL\Tests\FunctionalTestCase;
use Doctrine\DBAL\Tests\TestUtil;
use Doctrine\DBAL\Types\Types;
use PDO;

use function array_change_key_case;

Expand Down Expand Up @@ -558,7 +557,7 @@ private function prepareExpectedRows(array $rows): array
{
if (
TestUtil::isDriverOneOf('pdo_oci', 'pdo_sqlsrv', 'oci8')
|| (TestUtil::getConnectionParams()['driverOptions'][PDO::ATTR_STRINGIFY_FETCHES] ?? false) === true
|| TestUtil::isPdoStringifyFetchesEnabled()
) {
foreach ($rows as &$row) {
foreach ($row as &$value) {
Expand Down
8 changes: 7 additions & 1 deletion tests/Functional/SQL/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ public function testPostgreSQLJSONBQuestionOperator(): void
self::markTestSkipped('This test requires the pdo_pgsql driver.');
}

self::assertTrue($this->connection->fetchOne('SELECT \'{"a":null}\'::jsonb ?? :key', ['key' => 'a']));
$result = $this->connection->fetchOne('SELECT \'{"a":null}\'::jsonb ?? :key', ['key' => 'a']);

if (TestUtil::isPdoStringifyFetchesEnabled()) {
self::assertSame('1', $result);
} else {
self::assertTrue($result);
}
}
}
6 changes: 6 additions & 0 deletions tests/TestUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Doctrine\DBAL\Platforms\SQLitePlatform;
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
use InvalidArgumentException;
use PDO;
use PHPUnit\Framework\Assert;

use function array_map;
Expand Down Expand Up @@ -241,6 +242,11 @@ public static function isDriverOneOf(string ...$names): bool
return in_array($params['driver'], $names, true);
}

public static function isPdoStringifyFetchesEnabled(): bool
{
return (self::getConnectionParams()['driverOptions'][PDO::ATTR_STRINGIFY_FETCHES] ?? false) === true;
}

/**
* Generates a query that will return the given rows without the need to create a temporary table.
*
Expand Down