Skip to content

Commit

Permalink
Merge branch '4.0.x' into 4.1.x
Browse files Browse the repository at this point in the history
* 4.0.x:
  Properly handle MySQL error code 4031 from PHP 8.4 (doctrine#6363)
  CI: Add MySQL 9, reduce test matrix (doctrine#6462)
  Fix update/delete aliases in documentation (doctrine#6470)
  Complete sentence
  Docs: update custom platform example to use middlewares (doctrine#6460)
  ci: nightly - php-8.1 only + workflow_dispatch
  ci: nightly - php-8.1 min version (doctrine#6457)
  mariadb: add nightly workflow to facilitate mariadb "nightlies" (doctrine#6435)
  • Loading branch information
derrabus committed Jul 23, 2024
2 parents 6ebcb77 + 076828e commit ddfcfe6
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 26 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,11 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.3"
mysql-version:
- "5.7"
- "8.0"
- "9.0"
extension:
- "mysqli"
- "pdo_mysql"
Expand All @@ -363,18 +364,19 @@ jobs:
php-version: "8.1"
mysql-version: "8.0"
extension: "mysqli"
- php-version: "8.2"
- php-version: "8.1"
mysql-version: "8.0"
extension: "mysqli"
- php-version: "8.3"
- php-version: "8.1"
mysql-version: "8.0"
extension: "pdo_mysql"
- php-version: "8.1"
# Workaround for https://bugs.mysql.com/114876
- php-version: "8.3"
mysql-version: "8.4"
extension: "mysqli"
custom-entrypoint: >-
--entrypoint sh mysql:8.4 -c "exec docker-entrypoint.sh mysqld --mysql-native-password=ON"
- php-version: "8.1"
- php-version: "8.3"
mysql-version: "8.4"
extension: "pdo_mysql"
custom-entrypoint: >-
Expand Down
72 changes: 72 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: "Continuous Integration (Nightly)"

on:
schedule:
- cron: "12 3 * * *"
workflow_dispatch:

env:
fail-fast: true

jobs:
phpunit-mariadb:
name: "PHPUnit with MariaDB"
runs-on: "ubuntu-24.04"

strategy:
matrix:
php-version:
- "8.3"
mariadb-version:
- "earliest"
- "verylatest"
extension:
- "mysqli"
- "pdo_mysql"

services:
mariadb:
image: "quay.io/mariadb-foundation/mariadb-devel:${{ matrix.mariadb-version }}"
env:
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: yes
MARIADB_DATABASE: "doctrine_tests"

options: >-
--health-cmd "healthcheck.sh --connect --innodb_initialized"
ports:
- "3306:3306"

steps:
- name: "Checkout"
uses: "actions/checkout@v4"
with:
fetch-depth: 2

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
coverage: "pcov"
ini-values: "zend.assertions=1"
extensions: "${{ matrix.extension }}"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v3"
with:
composer-options: "--ignore-platform-req=php+"

- name: "Run PHPUnit"
run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml"

- name: Tell the MariaDB Folks if it failed
if: ${{ failure() }}
uses: zulip/github-actions-zulip/send-message@v1
with:
api-key: ${{ secrets.MARIADB_ZULIP_API_KEY }}
email: "[email protected]"
organization-url: "https://mariadb.zulipchat.com"
to: "Buildbot"
type: "stream"
topic: "CI - Doctrine/DBAL"
content: "There was an error running Doctrine on MariaDB:${{ matrix.mariadb-version }} - URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}."
34 changes: 24 additions & 10 deletions docs/en/reference/platforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,34 @@ database vendor and version best. Otherwise it is not guaranteed
that the compatibility in terms of SQL dialect and feature support
between Doctrine DBAL and the database server will always be given.

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

::

<?php
$myPlatform = new MyPlatform();
$options = [
'driver' => 'pdo_sqlite',
'path' => 'database.sqlite',
'platform' => $myPlatform,
];
$conn = DriverManager::getConnection($options);
class CustomSQLitePlatform extends SqlitePlatform {}

class CustomDriver extends AbstractDriverMiddleware
{
public function getDatabasePlatform(ServerVersionProvider $versionProvider)
{
return new CustomSQLitePlatform();
}
}

class CustomMiddleware implements Driver\Middleware
{
public function wrap(Driver $driver): Driver
{
return new CustomDriver($driver);
}
}

$config = new Doctrine\DBAL\Configuration();
$config->setMiddlewares([new CustomMiddleware()]);

$connection = DriverManager::getConnection($params, $config);

This way you can optimize your schema or generated SQL code with
features that might not be portable for instance, however are
Expand Down
2 changes: 1 addition & 1 deletion docs/en/reference/query-builder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ user-input:
<?php
$queryBuilder
->update('users', 'u')
->update('users u')
->set('u.logins', 'u.logins + 1')
->set('u.last_login', '?')
->setParameter(0, $userInputLastLogin)
Expand Down
3 changes: 2 additions & 1 deletion src/Driver/API/MySQL/ExceptionConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public function convert(Exception $exception, ?Query $query): DriverException
2002,
2005,
2054 => new ConnectionException($exception, $query),
2006 => new ConnectionLost($exception, $query),
2006,
4031 => new ConnectionLost($exception, $query),
1048,
1121,
1138,
Expand Down
14 changes: 7 additions & 7 deletions src/Query/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -636,8 +636,8 @@ public function addSelect(string $expression, string ...$expressions): self
*
* <code>
* $qb = $conn->createQueryBuilder()
* ->delete('users')
* ->where('users.id = :user_id')
* ->delete('users u')
* ->where('u.id = :user_id')
* ->setParameter(':user_id', 1);
* </code>
*
Expand All @@ -662,9 +662,9 @@ public function delete(string $table): self
*
* <code>
* $qb = $conn->createQueryBuilder()
* ->update('counters')
* ->set('counters.value', 'counters.value + 1')
* ->where('counters.id = ?');
* ->update('counters c')
* ->set('c.value', 'c.value + 1')
* ->where('c.id = ?');
* </code>
*
* @param string $table The table whose rows are subject to the update.
Expand Down Expand Up @@ -841,7 +841,7 @@ public function rightJoin(string $fromAlias, string $join, string $alias, ?strin
*
* <code>
* $qb = $conn->createQueryBuilder()
* ->update('counters', 'c')
* ->update('counters c')
* ->set('c.value', 'c.value + 1')
* ->where('c.id = ?');
* </code>
Expand Down Expand Up @@ -877,7 +877,7 @@ public function set(string $key, string $value): self
* $or->add($qb->expr()->eq('c.id', 1));
* $or->add($qb->expr()->eq('c.id', 2));
*
* $qb->update('counters', 'c')
* $qb->update('counters c')
* ->set('c.value', 'c.value + 1')
* ->where($or);
* </code>
Expand Down
3 changes: 2 additions & 1 deletion src/Schema/AbstractAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
* The abstract asset allows to reset the name of all assets without publishing this to the public userland.
*
* This encapsulation hack is necessary to keep a consistent state of the database schema. Say we have a list of tables
* array($tableName => Table($tableName)); if you want to rename the table, you have to make sure
* array($tableName => Table($tableName)); if you want to rename the table, you have to make sure this does not get
* recreated during schema migration.
*/
abstract class AbstractAsset
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Driver/VersionAwarePlatformDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public static function mySQLVersionProvider(): array
return [
['5.7.0', MySQLPlatform::class],
['8.0.11', MySQL80Platform::class],
['8.4.0', MySQL84Platform::class],
['8.4.1', MySQL84Platform::class],
['9.0.0', MySQL84Platform::class],
['5.5.40-MariaDB-1~wheezy', MariaDBPlatform::class],
['5.5.5-MariaDB-10.2.8+maria~xenial-log', MariaDBPlatform::class],
['10.2.8-MariaDB-10.2.8+maria~xenial-log', MariaDBPlatform::class],
Expand Down

0 comments on commit ddfcfe6

Please sign in to comment.