Skip to content

Commit dc30f52

Browse files
committed
Merge branch '4.4.x' into 5.0.x
* 4.4.x: Document the JSON_OBJECT type (doctrine#7054) [RFC] Introduce Types::JSON_OBJECT (doctrine#7053) feat: add more pdo jobs with stringify fetches (doctrine#7052) Fix case sensitivity in SQLite column types (doctrine#7050) Fix length type in `MySQLSchemaManager` with `ATTR_STRINGIFY_FETCHES` enabled (doctrine#7028) Fix Symfony 8 compatibility issues (doctrine#7009) Quote MySQL constraint names for foreign keys
2 parents 0cdee42 + 95bda94 commit dc30f52

26 files changed

+669
-75
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 24 additions & 2 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:
@@ -152,6 +164,10 @@ jobs:
152164
- php-version: "8.2"
153165
mariadb-version: "11.4"
154166
extension: "pdo_mysql"
167+
- config-file-suffix: "-stringify_fetches"
168+
php-version: "8.2"
169+
mariadb-version: "11.4"
170+
extension: "pdo_mysql"
155171

156172
phpunit-mysql:
157173
name: "PHPUnit with MySQL"
@@ -179,6 +195,10 @@ jobs:
179195
php-version: "8.2"
180196
mysql-version: "9.1"
181197
extension: "mysqli"
198+
- config-file-suffix: "-stringify_fetches"
199+
php-version: "8.2"
200+
mysql-version: "9.1"
201+
extension: "pdo_mysql"
182202
- php-version: "8.2"
183203
mysql-version: "9.1"
184204
extension: "mysqli"
@@ -232,7 +252,7 @@ jobs:
232252
strategy:
233253
matrix:
234254
php-version:
235-
- "8.3"
255+
- "8.4"
236256

237257
steps:
238258
- name: "Checkout"
@@ -246,7 +266,9 @@ jobs:
246266
fail-fast: true
247267

248268
- name: "Lower minimum stability"
249-
run: "composer config minimum-stability dev"
269+
run: |
270+
composer config minimum-stability dev
271+
composer require --no-update --dev symfony/console:^8 symfony/cache:^8
250272
251273
- name: "Install development dependencies with Composer"
252274
uses: "ramsey/composer-install@v3"

.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: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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_mysql"/>
17+
<!-- see \PDO::ATTR_STRINGIFY_FETCHES-->
18+
<var name="db_driver_option_17" value="true"/>
19+
<var name="db_host" value="127.0.0.1" />
20+
<var name="db_port" value="3306"/>
21+
<var name="db_user" value="root" />
22+
<var name="db_dbname" value="doctrine_tests" />
23+
<var name="db_charset" value="utf8mb4" />
24+
</php>
25+
26+
<testsuites>
27+
<testsuite name="Doctrine DBAL Test Suite">
28+
<directory>../../../tests</directory>
29+
</testsuite>
30+
</testsuites>
31+
32+
<source>
33+
<include>
34+
<directory>../../../src</directory>
35+
</include>
36+
</source>
37+
</phpunit>
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>

docs/en/reference/types.rst

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,21 @@ jsonb
476476
This type is similar to ``json``. On PostgreSQL, it is mapped to the ``JSONB`` data type.
477477
On all other platforms, it is mapped to the same type as ``json``.
478478

479+
.. _json_object:
480+
json_object
481+
^^^^^^^^^^^
482+
483+
This type is similar to ``json``. Values retrieved from the database are also always converted
484+
to PHP's native types using PHP's ``json_decode()`` function but this time JSON objects are
485+
always converted to PHP `\stdClass`.
486+
487+
.. _jsonb_object:
488+
jsonb_object
489+
^^^^^^^^^^^^
490+
491+
This type is similar to ``json_object``. On PostgreSQL, it is mapped to the ``JSONB`` data type.
492+
On all other platforms, it is mapped to the same type as ``json``.
493+
479494
.. _mappingMatrix:
480495

481496
Mapping Matrix
@@ -701,7 +716,7 @@ Please also notice the mapping specific footnotes for additional information.
701716
| | | **SQL Server** | *all* | ``VARCHAR(MAX)`` |
702717
+-------------------+--------------------+--------------------------+---------+----------------------------------------------------------+
703718
| **json** | ``mixed`` | **MySQL** | *all* | ``JSON`` |
704-
| | +--------------------------+ + |
719+
| | +--------------------------+ | |
705720
| | | **PostgreSQL** | *all* | |
706721
| | +--------------------------+---------+----------------------------------------------------------+
707722
| | | **Oracle** | *all* | ``CLOB`` |
@@ -720,6 +735,27 @@ Please also notice the mapping specific footnotes for additional information.
720735
| | +--------------------------+---------+----------------------------------------------------------+
721736
| | | **SQL Server** | *all* | ``VARCHAR(MAX)`` |
722737
+-------------------+--------------------+--------------------------+---------+----------------------------------------------------------+
738+
| **json_object** | ``mixed`` | **MySQL** | *all* | ``JSON`` |
739+
| | +--------------------------+ | |
740+
| | | **PostgreSQL** | *all* | |
741+
| | +--------------------------+---------+----------------------------------------------------------+
742+
| | | **Oracle** | *all* | ``CLOB`` |
743+
| | +--------------------------+ | |
744+
| | | **SQLite** | | |
745+
| | +--------------------------+---------+----------------------------------------------------------+
746+
| | | **SQL Server** | *all* | ``VARCHAR(MAX)`` |
747+
+-------------------+--------------------+--------------------------+---------+----------------------------------------------------------+
748+
| **jsonb_object** | ``mixed`` | **MySQL** | *all* | ``JSON`` |
749+
| | +--------------------------+---------+----------------------------------------------------------+
750+
| | | **PostgreSQL** | *all* | ``JSONB`` |
751+
| | +--------------------------+---------+----------------------------------------------------------+
752+
| | | **Oracle** | *all* | ``CLOB`` |
753+
| | +--------------------------+ | |
754+
| | | **SQLite** | | |
755+
| | +--------------------------+---------+----------------------------------------------------------+
756+
| | | **SQL Server** | *all* | ``VARCHAR(MAX)`` |
757+
+-------------------+--------------------+--------------------------+---------+----------------------------------------------------------+
758+
723759

724760
**Notes**
725761

src/Schema/MySQLSchemaManager.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ protected function _getPortableTableColumnDefinition(array $tableColumn): Column
125125
switch ($dbType) {
126126
case 'char':
127127
case 'varchar':
128-
$editor->setLength($tableColumn['character_maximum_length']);
128+
$editor->setLength((int) $tableColumn['character_maximum_length']);
129129
break;
130130

131131
case 'binary':
132132
case 'varbinary':
133-
$editor->setLength($tableColumn['character_octet_length']);
133+
$editor->setLength((int) $tableColumn['character_octet_length']);
134134
break;
135135

136136
case 'tinytext':
@@ -162,10 +162,10 @@ protected function _getPortableTableColumnDefinition(array $tableColumn): Column
162162
case 'real':
163163
case 'numeric':
164164
case 'decimal':
165-
$editor->setPrecision($tableColumn['numeric_precision']);
165+
$editor->setPrecision((int) $tableColumn['numeric_precision']);
166166

167167
if (isset($tableColumn['numeric_scale'])) {
168-
$editor->setScale($tableColumn['numeric_scale']);
168+
$editor->setScale((int) $tableColumn['numeric_scale']);
169169
}
170170

171171
break;
@@ -258,7 +258,7 @@ protected function _getPortableTableForeignKeysList(array $rows): array
258258
$row = array_change_key_case($row, CASE_LOWER);
259259
if (! isset($list[$row['constraint_name']])) {
260260
$list[$row['constraint_name']] = [
261-
'name' => $row['constraint_name'],
261+
'name' => $this->getQuotedIdentifierName($row['constraint_name']),
262262
'local' => [],
263263
'foreign' => [],
264264
'foreignTable' => $row['referenced_table_name'],
@@ -550,4 +550,14 @@ private function getDefaultTableOptions(): DefaultTableOptions
550550

551551
return $this->defaultTableOptions;
552552
}
553+
554+
/** Returns the quoted representation of the given identifier name. */
555+
private function getQuotedIdentifierName(?string $identifier): ?string
556+
{
557+
if ($identifier === null) {
558+
return null;
559+
}
560+
561+
return $this->platform->quoteSingleIdentifier($identifier);
562+
}
553563
}

src/Schema/SQLiteSchemaManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function dropForeignKey(string $name, string $table): void
6767
*/
6868
protected function _getPortableTableColumnDefinition(array $tableColumn): Column
6969
{
70-
$matchResult = preg_match('/^([A-Z\s]+?)(?:\s*\((\d+)(?:,\s*(\d+))?\))?$/', $tableColumn['type'], $matches);
70+
$matchResult = preg_match('/^([A-Z\s]+?)(?:\s*\((\d+)(?:,\s*(\d+))?\))?$/i', $tableColumn['type'], $matches);
7171
assert($matchResult === 1);
7272

7373
$editor = Column::editor()

0 commit comments

Comments
 (0)