Skip to content

Commit 162caab

Browse files
committed
Merge branch '4.1.x' into 5.0.x
* 4.1.x: Properly handle MySQL error code 4031 from PHP 8.4 (#6363) Add SmallFloat type (#6471) CI: Add MySQL 9, reduce test matrix (#6462) Fix update/delete aliases in documentation (#6470) Complete sentence Docs: update custom platform example to use middlewares (#6460) ci: nightly - php-8.1 only + workflow_dispatch ci: nightly - php-8.1 min version (#6457) mariadb: add nightly workflow to facilitate mariadb "nightlies" (#6435)
2 parents 7d3b1ef + 886decf commit 162caab

30 files changed

+317
-45
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,10 @@ jobs:
348348
strategy:
349349
matrix:
350350
php-version:
351-
- "8.1"
351+
- "8.3"
352352
mysql-version:
353353
- "8.0"
354+
- "9.0"
354355
extension:
355356
- "mysqli"
356357
- "pdo_mysql"
@@ -361,18 +362,19 @@ jobs:
361362
php-version: "8.1"
362363
mysql-version: "8.0"
363364
extension: "mysqli"
364-
- php-version: "8.2"
365+
- php-version: "8.1"
365366
mysql-version: "8.0"
366367
extension: "mysqli"
367-
- php-version: "8.3"
368+
- php-version: "8.1"
368369
mysql-version: "8.0"
369370
extension: "pdo_mysql"
370-
- php-version: "8.1"
371+
# Workaround for https://bugs.mysql.com/114876
372+
- php-version: "8.3"
371373
mysql-version: "8.4"
372374
extension: "mysqli"
373375
custom-entrypoint: >-
374376
--entrypoint sh mysql:8.4 -c "exec docker-entrypoint.sh mysqld --mysql-native-password=ON"
375-
- php-version: "8.1"
377+
- php-version: "8.3"
376378
mysql-version: "8.4"
377379
extension: "pdo_mysql"
378380
custom-entrypoint: >-

.github/workflows/nightly.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: "Continuous Integration (Nightly)"
2+
3+
on:
4+
schedule:
5+
- cron: "12 3 * * *"
6+
workflow_dispatch:
7+
8+
env:
9+
fail-fast: true
10+
11+
jobs:
12+
phpunit-mariadb:
13+
name: "PHPUnit with MariaDB"
14+
runs-on: "ubuntu-24.04"
15+
16+
strategy:
17+
matrix:
18+
php-version:
19+
- "8.3"
20+
mariadb-version:
21+
- "earliest"
22+
- "verylatest"
23+
extension:
24+
- "mysqli"
25+
- "pdo_mysql"
26+
27+
services:
28+
mariadb:
29+
image: "quay.io/mariadb-foundation/mariadb-devel:${{ matrix.mariadb-version }}"
30+
env:
31+
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: yes
32+
MARIADB_DATABASE: "doctrine_tests"
33+
34+
options: >-
35+
--health-cmd "healthcheck.sh --connect --innodb_initialized"
36+
37+
ports:
38+
- "3306:3306"
39+
40+
steps:
41+
- name: "Checkout"
42+
uses: "actions/checkout@v4"
43+
with:
44+
fetch-depth: 2
45+
46+
- name: "Install PHP"
47+
uses: "shivammathur/setup-php@v2"
48+
with:
49+
php-version: "${{ matrix.php-version }}"
50+
coverage: "pcov"
51+
ini-values: "zend.assertions=1"
52+
extensions: "${{ matrix.extension }}"
53+
54+
- name: "Install dependencies with Composer"
55+
uses: "ramsey/composer-install@v3"
56+
with:
57+
composer-options: "--ignore-platform-req=php+"
58+
59+
- name: "Run PHPUnit"
60+
run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml"
61+
62+
- name: Tell the MariaDB Folks if it failed
63+
if: ${{ failure() }}
64+
uses: zulip/github-actions-zulip/send-message@v1
65+
with:
66+
api-key: ${{ secrets.MARIADB_ZULIP_API_KEY }}
67+
68+
organization-url: "https://mariadb.zulipchat.com"
69+
to: "Buildbot"
70+
type: "stream"
71+
topic: "CI - Doctrine/DBAL"
72+
content: "There was an error running Doctrine on MariaDB:${{ matrix.mariadb-version }} - URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}."

docs/en/reference/platforms.rst

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,34 @@ database vendor and version best. Otherwise it is not guaranteed
7474
that the compatibility in terms of SQL dialect and feature support
7575
between Doctrine DBAL and the database server will always be given.
7676

77-
If you want to overwrite parts of your platform you can do so when
78-
creating a connection. There is a ``platform`` option you can pass
79-
an instance of the platform you want the connection to use:
77+
If you want to overwrite parts of your platform you can do so by
78+
using a middleware:
8079

8180
::
8281

8382
<?php
84-
$myPlatform = new MyPlatform();
85-
$options = [
86-
'driver' => 'pdo_sqlite',
87-
'path' => 'database.sqlite',
88-
'platform' => $myPlatform,
89-
];
90-
$conn = DriverManager::getConnection($options);
83+
class CustomSQLitePlatform extends SqlitePlatform {}
84+
85+
class CustomDriver extends AbstractDriverMiddleware
86+
{
87+
public function getDatabasePlatform(ServerVersionProvider $versionProvider)
88+
{
89+
return new CustomSQLitePlatform();
90+
}
91+
}
92+
93+
class CustomMiddleware implements Driver\Middleware
94+
{
95+
public function wrap(Driver $driver): Driver
96+
{
97+
return new CustomDriver($driver);
98+
}
99+
}
100+
101+
$config = new Doctrine\DBAL\Configuration();
102+
$config->setMiddlewares([new CustomMiddleware()]);
103+
104+
$connection = DriverManager::getConnection($params, $config);
91105

92106
This way you can optimize your schema or generated SQL code with
93107
features that might not be portable for instance, however are

docs/en/reference/query-builder.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ user-input:
309309
<?php
310310
311311
$queryBuilder
312-
->update('users', 'u')
312+
->update('users u')
313313
->set('u.logins', 'u.logins + 1')
314314
->set('u.last_login', '?')
315315
->setParameter(0, $userInputLastLogin)

docs/en/reference/types.rst

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,21 @@ or ``null`` if no data is present.
125125
it approximates precision which can lead to false assumptions in
126126
applications.
127127

128+
smallfloat
129+
++++++++++
130+
131+
Maps and converts single precision floating-point values.
132+
This type is suitable for storing numeric data with approximate precision, where 4-byte (32-bit) storage is sufficient.
133+
Single precision values typically have a wide range, accommodating most numerical requirements with a precision of up to 7 decimal digits.
134+
Values retrieved from the database are always converted to PHP's ``float``/``double`` type or ``null`` if no data is present.
135+
128136
float
129137
+++++
130138

131-
Maps and converts numeric data with floating-point precision.
132-
If you only need an approximate precision for numbers with fractions, you should
133-
consider using this type.
134-
Values retrieved from the database are always converted to PHP's
139+
Maps and converts double precision floating-point values.
140+
This type is suitable for storing numeric data with higher precision, requiring 8-byte (64-bit) storage.
141+
Double precision values typically offer an extensive range, meeting the demands of more precise calculations
142+
with a precision of up to 15 decimal digits. Values retrieved from the database are always converted to PHP's
135143
``float``/``double`` type or ``null`` if no data is present.
136144

137145
String types
@@ -572,6 +580,16 @@ Please also notice the mapping specific footnotes for additional information.
572580
| | +--------------------------+ | |
573581
| | | **SQLite** | | |
574582
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
583+
| **smallfloat** | ``float`` | **MySQL** | *all* | ``FLOAT`` ``UNSIGNED`` [10] |
584+
| | +--------------------------+---------+----------------------------------------------------------+
585+
| | | **PostgreSQL** | *all* | ``REAL`` |
586+
| | +--------------------------+ | |
587+
| | | **Oracle** | | |
588+
| | +--------------------------+ | |
589+
| | | **SQL Server** | | |
590+
| | +--------------------------+ | |
591+
| | | **SQLite** | | |
592+
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
575593
| **float** | ``float`` | **MySQL** | *all* | ``DOUBLE PRECISION`` ``UNSIGNED`` [10] |
576594
| | +--------------------------+---------+----------------------------------------------------------+
577595
| | | **PostgreSQL** | *all* | ``DOUBLE PRECISION`` |

src/Driver/API/MySQL/ExceptionConverter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ public function convert(Exception $exception, ?Query $query): DriverException
7878
2002,
7979
2005,
8080
2054 => new ConnectionException($exception, $query),
81-
2006 => new ConnectionLost($exception, $query),
81+
2006,
82+
4031 => new ConnectionLost($exception, $query),
8283
1048,
8384
1121,
8485
1138,

src/Platforms/AbstractMySQLPlatform.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,14 @@ public function getFloatDeclarationSQL(array $column): string
639639
return 'DOUBLE PRECISION' . $this->getUnsignedDeclaration($column);
640640
}
641641

642+
/**
643+
* {@inheritDoc}
644+
*/
645+
public function getSmallFloatDeclarationSQL(array $column): string
646+
{
647+
return 'FLOAT' . $this->getUnsignedDeclaration($column);
648+
}
649+
642650
/**
643651
* {@inheritDoc}
644652
*/
@@ -720,7 +728,7 @@ protected function initializeDoctrineTypeMappings(): void
720728
'datetime' => Types::DATETIME_MUTABLE,
721729
'decimal' => Types::DECIMAL,
722730
'double' => Types::FLOAT,
723-
'float' => Types::FLOAT,
731+
'float' => Types::SMALLFLOAT,
724732
'int' => Types::INTEGER,
725733
'integer' => Types::INTEGER,
726734
'json' => Types::JSON,

src/Platforms/AbstractPlatform.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,6 +1877,12 @@ public function getFloatDeclarationSQL(array $column): string
18771877
return 'DOUBLE PRECISION';
18781878
}
18791879

1880+
/** @param mixed[] $column */
1881+
public function getSmallFloatDeclarationSQL(array $column): string
1882+
{
1883+
return 'REAL';
1884+
}
1885+
18801886
/**
18811887
* Gets the default transaction isolation level of the platform.
18821888
*

src/Platforms/DB2Platform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function initializeDoctrineTypeMappings(): void
5252
'decimal' => Types::DECIMAL,
5353
'double' => Types::FLOAT,
5454
'integer' => Types::INTEGER,
55-
'real' => Types::FLOAT,
55+
'real' => Types::SMALLFLOAT,
5656
'smallint' => Types::SMALLINT,
5757
'time' => Types::TIME_MUTABLE,
5858
'timestamp' => Types::DATETIME_MUTABLE,

src/Platforms/OraclePlatform.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,7 @@ protected function initializeDoctrineTypeMappings(): void
750750
'nvarchar2' => Types::STRING,
751751
'pls_integer' => Types::BOOLEAN,
752752
'raw' => Types::BINARY,
753+
'real' => Types::SMALLFLOAT,
753754
'rowid' => Types::STRING,
754755
'timestamp' => Types::DATETIME_MUTABLE,
755756
'timestamptz' => Types::DATETIMETZ_MUTABLE,

0 commit comments

Comments
 (0)