Skip to content

Commit d5533f9

Browse files
authored
feat: add more pdo jobs with stringify fetches (#7052)
<!-- Fill in the relevant information below to help triage your pull request. --> | Q | A |------------- | ----------- | Type | improvement #### Summary Add more unit test jobs that use the PDO::STRINGIFY_FETCHES option, as discussed in this PR: #7028 (review) I didn't add a job for `pdo_oci` and `pdo_sqlsrv` as for those drivers the result in `QueryBuilderTest` was already stringified, therefore I assume those drivers always stringify the fetches, therefore a separate job is not needed
1 parent ac336c9 commit d5533f9

File tree

12 files changed

+128
-14
lines changed

12 files changed

+128
-14
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
php-version: ${{ matrix.php-version }}
3636
extension: ${{ matrix.extension }}
3737
dependency-versions: ${{ matrix.dependency-versions }}
38+
config-file-suffix: ${{ matrix.config-file-suffix }}
3839

3940
strategy:
4041
matrix:
@@ -57,6 +58,11 @@ jobs:
5758
php-version: "8.4"
5859
dependency-versions: "highest"
5960
extension: "sqlite3"
61+
- os: "ubuntu-22.04"
62+
php-version: "8.2"
63+
dependency-versions: "highest"
64+
extension: "pdo_sqlite"
65+
config-file-suffix: "-stringify_fetches"
6066

6167
phpunit-oracle:
6268
name: "PHPUnit with Oracle"
@@ -95,6 +101,7 @@ jobs:
95101
postgres-version: ${{ matrix.postgres-version }}
96102
extension: ${{ matrix.extension }}
97103
postgres-locale-provider: ${{ matrix.postgres-locale-provider }}
104+
config-file-suffix: ${{ matrix.config-file-suffix }}
98105

99106
strategy:
100107
matrix:
@@ -121,6 +128,10 @@ jobs:
121128
postgres-version: "15"
122129
extension: "pdo_pgsql"
123130
postgres-locale-provider: "icu"
131+
- php-version: "8.2"
132+
postgres-version: "17"
133+
extension: "pdo_pgsql"
134+
config-file-suffix: "-stringify_fetches"
124135

125136
phpunit-mariadb:
126137
name: "PHPUnit with MariaDB"
@@ -130,6 +141,7 @@ jobs:
130141
php-version: ${{ matrix.php-version }}
131142
mariadb-version: ${{ matrix.mariadb-version }}
132143
extension: ${{ matrix.extension }}
144+
config-file-suffix: ${{ matrix.config-file-suffix }}
133145

134146
strategy:
135147
matrix:
@@ -154,6 +166,10 @@ jobs:
154166
- php-version: "8.2"
155167
mariadb-version: "11.4"
156168
extension: "pdo_mysql"
169+
- config-file-suffix: "-stringify_fetches"
170+
php-version: "8.2"
171+
mariadb-version: "11.4"
172+
extension: "pdo_mysql"
157173

158174
phpunit-mysql:
159175
name: "PHPUnit with MySQL"

.github/workflows/phpunit-mariadb.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
extension:
1313
required: true
1414
type: string
15+
config-file-suffix:
16+
required: false
17+
type: string
18+
default: ''
1519

1620
jobs:
1721
phpunit-mariadb:
@@ -53,5 +57,5 @@ jobs:
5357
- name: Upload coverage file
5458
uses: actions/upload-artifact@v4
5559
with:
56-
name: ${{ github.job }}-${{ inputs.mariadb-version }}-php-${{ inputs.php-version }}-${{ inputs.extension }}.coverage
60+
name: ${{ github.job }}-${{ inputs.mariadb-version }}-php-${{ inputs.php-version }}-${{ inputs.extension }}${{ inputs.config-file-suffix }}.coverage
5761
path: coverage.xml

.github/workflows/phpunit-postgres.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ on:
1515
postgres-locale-provider:
1616
required: true
1717
type: string
18+
config-file-suffix:
19+
required: false
20+
type: string
21+
default: ''
1822

1923
jobs:
2024
phpunit-postgres:
@@ -51,10 +55,10 @@ jobs:
5155
composer-options: '--ignore-platform-req=php+'
5256

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

5660
- name: Upload coverage file
5761
uses: actions/upload-artifact@v4
5862
with:
59-
name: ${{ github.job }}-${{ inputs.postgres-version }}-php-${{ inputs.php-version }}-${{ inputs.extension }}.coverage
63+
name: ${{ github.job }}-${{ inputs.postgres-version }}-php-${{ inputs.php-version }}-${{ inputs.extension }}${{ inputs.config-file-suffix }}.coverage
6064
path: coverage.xml

.github/workflows/phpunit-sqlite.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ on:
1515
dependency-versions:
1616
required: true
1717
type: string
18+
config-file-suffix:
19+
required: false
20+
type: string
21+
default: ''
1822

1923
jobs:
2024
phpunit-sqlite:
@@ -50,10 +54,10 @@ jobs:
5054
if: ${{ inputs.extension == 'sqlite3' }}
5155

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

5559
- name: Upload coverage file
5660
uses: actions/upload-artifact@v4
5761
with:
58-
name: ${{ github.job }}-php-${{ inputs.php-version }}-${{ inputs.extension }}-${{ inputs.dependency-versions }}.coverage
62+
name: ${{ github.job }}-php-${{ inputs.php-version }}-${{ inputs.extension }}${{ inputs.config-file-suffix }}-${{ inputs.dependency-versions }}.coverage
5963
path: coverage.xml
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
4+
colors="true"
5+
beStrictAboutOutputDuringTests="true"
6+
failOnRisky="true"
7+
failOnWarning="true"
8+
failOnNotice="true"
9+
failOnPhpunitDeprecation="true"
10+
displayDetailsOnTestsThatTriggerErrors="true"
11+
displayDetailsOnTestsThatTriggerDeprecations="true"
12+
>
13+
<php>
14+
<ini name="error_reporting" value="-1" />
15+
16+
<var name="db_driver" value="pdo_pgsql"/>
17+
<!-- see \PDO::ATTR_STRINGIFY_FETCHES-->
18+
<var name="db_driver_option_17" value="true"/>
19+
<var name="db_host" value="localhost" />
20+
<var name="db_user" value="postgres" />
21+
<var name="db_password" value="postgres" />
22+
<var name="db_dbname" value="doctrine_tests" />
23+
</php>
24+
25+
<testsuites>
26+
<testsuite name="Doctrine DBAL Test Suite">
27+
<directory>../../../tests</directory>
28+
</testsuite>
29+
</testsuites>
30+
31+
<source>
32+
<include>
33+
<directory>../../../src</directory>
34+
</include>
35+
</source>
36+
</phpunit>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
4+
colors="true"
5+
beStrictAboutOutputDuringTests="true"
6+
failOnRisky="true"
7+
failOnWarning="true"
8+
failOnNotice="true"
9+
failOnPhpunitDeprecation="true"
10+
displayDetailsOnTestsThatTriggerErrors="true"
11+
displayDetailsOnTestsThatTriggerDeprecations="true"
12+
>
13+
<php>
14+
<ini name="error_reporting" value="-1" />
15+
16+
<var name="db_driver" value="pdo_sqlite"/>
17+
<!-- see \PDO::ATTR_STRINGIFY_FETCHES-->
18+
<var name="db_driver_option_17" value="true"/>
19+
<var name="db_memory" value="true"/>
20+
</php>
21+
22+
<testsuites>
23+
<testsuite name="Doctrine DBAL Test Suite">
24+
<directory>../../../tests</directory>
25+
</testsuite>
26+
</testsuites>
27+
28+
<source>
29+
<include>
30+
<directory>../../../src</directory>
31+
</include>
32+
</source>
33+
</phpunit>

src/Schema/PostgreSQLSchemaManager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ protected function _getPortableTableForeignKeyDefinition(array $tableForeignKey)
128128
[
129129
'onUpdate' => $onUpdate,
130130
'onDelete' => $onDelete,
131-
'deferrable' => $tableForeignKey['condeferrable'],
132-
'deferred' => $tableForeignKey['condeferred'],
131+
'deferrable' => (bool) $tableForeignKey['condeferrable'],
132+
'deferred' => (bool) $tableForeignKey['condeferred'],
133133
],
134134
);
135135
}
@@ -170,7 +170,7 @@ static function (array $row): array {
170170
return [
171171
'key_name' => $row['relname'],
172172
'non_unique' => ! $row['indisunique'],
173-
'primary' => $row['indisprimary'],
173+
'primary' => (bool) $row['indisprimary'],
174174
'where' => $row['where'],
175175
'column_name' => $row['attname'],
176176
];

tests/Functional/Driver/DBAL6044Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ protected function setUp(): void
1616
{
1717
parent::setUp();
1818

19-
if (TestUtil::isDriverOneOf('pdo_pgsql', 'pgsql')) {
19+
if (TestUtil::isDriverOneOf('pdo_pgsql', 'pgsql') && ! TestUtil::isPdoStringifyFetchesEnabled()) {
2020
return;
2121
}
2222

tests/Functional/FetchBooleanTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,23 @@
66

77
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
88
use Doctrine\DBAL\Tests\FunctionalTestCase;
9+
use Doctrine\DBAL\Tests\TestUtil;
910
use PHPUnit\Framework\Attributes\DataProvider;
1011

1112
class FetchBooleanTest extends FunctionalTestCase
1213
{
1314
protected function setUp(): void
1415
{
15-
if ($this->connection->getDatabasePlatform() instanceof PostgreSQLPlatform) {
16+
if (
17+
$this->connection->getDatabasePlatform() instanceof PostgreSQLPlatform
18+
&& ! TestUtil::isPdoStringifyFetchesEnabled()
19+
) {
1620
return;
1721
}
1822

19-
self::markTestSkipped('Only PostgreSQL supports boolean values natively');
23+
self::markTestSkipped(
24+
'Only PostgreSQL supports boolean values natively, as long as PDO does not stringify them.',
25+
);
2026
}
2127

2228
#[DataProvider('booleanLiteralProvider')]

tests/Functional/Query/QueryBuilderTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use Doctrine\DBAL\Tests\FunctionalTestCase;
2525
use Doctrine\DBAL\Tests\TestUtil;
2626
use Doctrine\DBAL\Types\Types;
27-
use PDO;
2827

2928
use function array_change_key_case;
3029

@@ -558,7 +557,7 @@ private function prepareExpectedRows(array $rows): array
558557
{
559558
if (
560559
TestUtil::isDriverOneOf('pdo_oci', 'pdo_sqlsrv', 'oci8')
561-
|| (TestUtil::getConnectionParams()['driverOptions'][PDO::ATTR_STRINGIFY_FETCHES] ?? false) === true
560+
|| TestUtil::isPdoStringifyFetchesEnabled()
562561
) {
563562
foreach ($rows as &$row) {
564563
foreach ($row as &$value) {

0 commit comments

Comments
 (0)