Skip to content

Commit

Permalink
Merge branch '3.8.x' into 4.0.x
Browse files Browse the repository at this point in the history
* 3.8.x:
  Enable skipping locked rows in QueryBuilder
  Fix coding standard violation
  Remove unused unit test fixtures
  Add Oracle v23 to CI testing (doctrine#6217)
  Extend `AbstractMySQLPlatform::getColumnTypeSQLSnippets()` deprecation layer (doctrine#6215)
  Deprecate AbstractMySQLPlatform::getColumnTypeSQLSnippets() (doctrine#6213)
  Fix MariaDB list columns performance (doctrine#6202)
  • Loading branch information
derrabus committed Nov 11, 2023
2 parents 8134e7c + c78222e commit 304e3ec
Show file tree
Hide file tree
Showing 30 changed files with 777 additions and 77 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ jobs:
oracle-version:
- "18"
- "21"
- "23"

services:
oracle:
image: gvenzl/oracle-xe:${{ matrix.oracle-version }}
image: gvenzl/oracle-${{ matrix.oracle-version < 23 && 'xe' || 'free' }}:${{ matrix.oracle-version }}
env:
ORACLE_PASSWORD: oracle
ports:
Expand Down Expand Up @@ -140,7 +141,7 @@ jobs:
composer-options: "--ignore-platform-req=php+"

- name: "Run PHPUnit"
run: "vendor/bin/phpunit -c ci/github/phpunit/oci8.xml --coverage-clover=coverage.xml"
run: "vendor/bin/phpunit -c ci/github/phpunit/oci8${{ matrix.oracle-version < 23 && '-21' || '' }}.xml --coverage-clover=coverage.xml"

- name: "Upload coverage file"
uses: "actions/upload-artifact@v3"
Expand All @@ -162,10 +163,11 @@ jobs:
oracle-version:
- "18"
- "21"
- "23"

services:
oracle:
image: gvenzl/oracle-xe:${{ matrix.oracle-version }}
image: gvenzl/oracle-${{ matrix.oracle-version < 23 && 'xe' || 'free' }}:${{ matrix.oracle-version }}
env:
ORACLE_PASSWORD: oracle
ports:
Expand Down Expand Up @@ -196,7 +198,7 @@ jobs:
composer-options: "--ignore-platform-req=php+"

- name: "Run PHPUnit"
run: "vendor/bin/phpunit -c ci/github/phpunit/pdo_oci.xml --coverage-clover=coverage.xml"
run: "vendor/bin/phpunit -c ci/github/phpunit/pdo_oci${{ matrix.oracle-version < 23 && '-21' || '' }}.xml --coverage-clover=coverage.xml"

- name: "Upload coverage file"
uses: "actions/upload-artifact@v3"
Expand Down
12 changes: 12 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,18 @@ The following methods have been removed.

# Upgrade to 3.8

## Deprecated lock-related `AbstractPlatform` methods

The usage of `AbstractPlatform::getReadLockSQL()`, `::getWriteLockSQL()` and `::getForUpdateSQL` is deprecated as this
API is not portable. Use `QueryBuilder::forUpdate()` as a replacement for the latter.

## Deprecated `AbstractMySQLPlatform` methods

* `AbstractMySQLPlatform::getColumnTypeSQLSnippets()` has been deprecated
in favor of `AbstractMySQLPlatform::getColumnTypeSQLSnippet()`.
* `AbstractMySQLPlatform::getDatabaseNameSQL()` has been deprecated without replacement.
* Not passing a database name to `AbstractMySQLPlatform::getColumnTypeSQLSnippet()` has been deprecated.

## Deprecated reset methods from `QueryBuilder`

`QueryBuilder::resetQueryParts()` has been deprecated.
Expand Down
39 changes: 39 additions & 0 deletions ci/github/phpunit/oci8-21.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?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"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
convertDeprecationsToExceptions="true"
>
<php>
<ini name="error_reporting" value="-1" />

<var name="db_driver" value="oci8"/>
<var name="db_host" value="localhost"/>
<var name="db_user" value="doctrine"/>
<var name="db_password" value="oracle"/>
<var name="db_dbname" value="XE"/>
<var name="db_charset" value="AL32UTF8" />

<var name="tmpdb_driver" value="oci8"/>
<var name="tmpdb_host" value="localhost"/>
<var name="tmpdb_user" value="system"/>
<var name="tmpdb_password" value="oracle"/>
<var name="tmpdb_dbname" value="XE"/>
</php>

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

<coverage>
<include>
<directory suffix=".php">../../../src</directory>
</include>
</coverage>
</phpunit>
4 changes: 2 additions & 2 deletions ci/github/phpunit/oci8.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
<var name="db_host" value="localhost"/>
<var name="db_user" value="doctrine"/>
<var name="db_password" value="oracle"/>
<var name="db_dbname" value="XE"/>
<var name="db_dbname" value="FREE"/>
<var name="db_charset" value="AL32UTF8" />

<var name="tmpdb_driver" value="oci8"/>
<var name="tmpdb_host" value="localhost"/>
<var name="tmpdb_user" value="system"/>
<var name="tmpdb_password" value="oracle"/>
<var name="tmpdb_dbname" value="XE"/>
<var name="tmpdb_dbname" value="FREE"/>
</php>

<testsuites>
Expand Down
39 changes: 39 additions & 0 deletions ci/github/phpunit/pdo_oci-21.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?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"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
convertDeprecationsToExceptions="true"
>
<php>
<ini name="error_reporting" value="-1" />

<var name="db_driver" value="pdo_oci"/>
<var name="db_host" value="localhost"/>
<var name="db_user" value="doctrine"/>
<var name="db_password" value="oracle"/>
<var name="db_dbname" value="XE"/>
<var name="db_charset" value="AL32UTF8" />

<var name="tmpdb_driver" value="pdo_oci"/>
<var name="tmpdb_host" value="localhost"/>
<var name="tmpdb_user" value="system"/>
<var name="tmpdb_password" value="oracle"/>
<var name="tmpdb_dbname" value="XE"/>
</php>

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

<coverage>
<include>
<directory suffix=".php">../../../src</directory>
</include>
</coverage>
</phpunit>
4 changes: 2 additions & 2 deletions ci/github/phpunit/pdo_oci.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
<var name="db_host" value="localhost"/>
<var name="db_user" value="doctrine"/>
<var name="db_password" value="oracle"/>
<var name="db_dbname" value="XE"/>
<var name="db_dbname" value="FREE"/>
<var name="db_charset" value="AL32UTF8" />

<var name="tmpdb_driver" value="pdo_oci"/>
<var name="tmpdb_host" value="localhost"/>
<var name="tmpdb_user" value="system"/>
<var name="tmpdb_password" value="oracle"/>
<var name="tmpdb_dbname" value="XE"/>
<var name="tmpdb_dbname" value="FREE"/>
</php>

<testsuites>
Expand Down
11 changes: 11 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,19 @@
</ConflictingReferenceConstraint>
<DeprecatedMethod>
<errorLevel type="suppress">
<!--
See https://github.com/doctrine/dbal/pull/6202
TODO: remove in 4.0.0
-->
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractMySQLPlatform::getColumnTypeSQLSnippets" />
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractMySQLPlatform::getDatabaseNameSQL" />

<!-- TODO for PHPUnit 11 -->
<referencedMethod name="PHPUnit\Framework\TestCase::iniSet"/>

<!-- TODO: remove in 4.0.0 -->
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getForUpdateSQL"/>
<referencedMethod name="Doctrine\DBAL\Platforms\DB2Platform::getForUpdateSQL"/>
</errorLevel>
</DeprecatedMethod>
<DocblockTypeContradiction>
Expand Down
5 changes: 5 additions & 0 deletions src/Driver/AbstractMySQLDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Platforms\Exception\InvalidPlatformVersion;
use Doctrine\DBAL\Platforms\MariaDB1052Platform;
use Doctrine\DBAL\Platforms\MariaDB1060Platform;
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Platforms\MySQL80Platform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
Expand All @@ -33,6 +34,10 @@ public function getDatabasePlatform(ServerVersionProvider $versionProvider): Abs
$version = $versionProvider->getServerVersion();
if (stripos($version, 'mariadb') !== false) {
$mariaDbVersion = $this->getMariaDbMysqlVersionNumber($version);
if (version_compare($mariaDbVersion, '10.6.0', '>=')) {
return new MariaDB1060Platform();
}

if (version_compare($mariaDbVersion, '10.5.2', '>=')) {
return new MariaDB1052Platform();
}
Expand Down
1 change: 1 addition & 0 deletions src/Driver/OCI8/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use SensitiveParameter;

use function oci_connect;
use function oci_new_connect;
use function oci_pconnect;

use const OCI_NO_AUTO_COMMIT;
Expand Down
30 changes: 29 additions & 1 deletion src/Platforms/AbstractMySQLPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\MySQLSchemaManager;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\SQL\Builder\DefaultSelectSQLBuilder;
use Doctrine\DBAL\SQL\Builder\SelectSQLBuilder;
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types\Types;
use Doctrine\Deprecations\Deprecation;

use function array_merge;
use function array_unique;
use function array_values;
use function count;
use function func_get_args;
use function implode;
use function in_array;
use function is_numeric;
Expand Down Expand Up @@ -216,6 +220,8 @@ public function supportsColumnCollation(): bool
}

/**
* @deprecated Use {@see getColumnTypeSQLSnippet()} instead.
*
* The SQL snippets required to elucidate a column type
*
* Returns an array of the form [column type SELECT snippet, additional JOIN statement snippet]
Expand All @@ -224,7 +230,24 @@ public function supportsColumnCollation(): bool
*/
public function getColumnTypeSQLSnippets(string $tableAlias = 'c'): array
{
return [$tableAlias . '.COLUMN_TYPE', ''];
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/6202',
'AbstractMySQLPlatform::getColumnTypeSQLSnippets() is deprecated. '
. 'Use AbstractMySQLPlatform::getColumnTypeSQLSnippet() instead.',
);

return [$this->getColumnTypeSQLSnippet(...func_get_args()), ''];
}

/**
* The SQL snippet required to elucidate a column type
*
* Returns a column type SELECT snippet string
*/
public function getColumnTypeSQLSnippet(string $tableAlias, string $databaseName): string
{
return $tableAlias . '.COLUMN_TYPE';
}

/**
Expand Down Expand Up @@ -282,6 +305,11 @@ protected function _getCreateTableSQL(string $name, array $columns, array $optio
return $sql;
}

public function createSelectSQLBuilder(): SelectSQLBuilder
{
return new DefaultSelectSQLBuilder($this, 'FOR UPDATE', null);
}

/**
* Build SQL for table options
*
Expand Down
35 changes: 35 additions & 0 deletions src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Schema\UniqueConstraint;
use Doctrine\DBAL\SQL\Builder\DefaultSelectSQLBuilder;
use Doctrine\DBAL\SQL\Builder\SelectSQLBuilder;
use Doctrine\DBAL\SQL\Parser;
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types;
use Doctrine\DBAL\Types\Exception\TypeNotFound;
use Doctrine\DBAL\Types\Type;
use Doctrine\Deprecations\Deprecation;

use function addcslashes;
use function array_map;
Expand Down Expand Up @@ -700,9 +703,18 @@ abstract public function getCurrentDatabaseExpression(): string;

/**
* Returns the FOR UPDATE expression.
*
* @deprecated This API is not portable. Use {@link QueryBuilder::forUpdate()}` instead.
*/
public function getForUpdateSQL(): string
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/6191',
'%s is deprecated as non-portable.',
__METHOD__,
);

return 'FOR UPDATE';
}

Expand All @@ -722,19 +734,37 @@ public function appendLockHint(string $fromClause, LockMode $lockMode): string
*
* This defaults to the ANSI SQL "FOR UPDATE", which is an exclusive lock (Write). Some database
* vendors allow to lighten this constraint up to be a real read lock.
*
* @deprecated This API is not portable.
*/
public function getReadLockSQL(): string
{
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/6191',
'%s is deprecated as non-portable.',
__METHOD__,
);

return $this->getForUpdateSQL();
}

/**
* Returns the SQL snippet to append to any SELECT statement which obtains an exclusive lock on the rows.
*
* The semantics of this lock mode should equal the SELECT .. FOR UPDATE of the ANSI SQL standard.
*
* @deprecated This API is not portable.
*/
public function getWriteLockSQL(): string
{
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/6191',
'%s is deprecated as non-portable.',
__METHOD__,
);

return $this->getForUpdateSQL();
}

Expand Down Expand Up @@ -799,6 +829,11 @@ public function getCreateTableSQL(Table $table): array
return $this->buildCreateTableSQL($table, true);
}

public function createSelectSQLBuilder(): SelectSQLBuilder
{
return new DefaultSelectSQLBuilder($this, 'FOR UPDATE', 'SKIP LOCKED');
}

/**
* @internal
*
Expand Down
8 changes: 8 additions & 0 deletions src/Platforms/DB2Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use Doctrine\DBAL\Schema\Identifier;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\SQL\Builder\DefaultSelectSQLBuilder;
use Doctrine\DBAL\SQL\Builder\SelectSQLBuilder;
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types\Types;

Expand Down Expand Up @@ -557,6 +559,12 @@ public function supportsIdentityColumns(): bool
return true;
}

public function createSelectSQLBuilder(): SelectSQLBuilder
{
return new DefaultSelectSQLBuilder($this, 'WITH RR USE AND KEEP UPDATE LOCKS', null);
}

/** @deprecated This API is not portable. */
public function getForUpdateSQL(): string
{
return ' WITH RR USE AND KEEP UPDATE LOCKS';
Expand Down
Loading

0 comments on commit 304e3ec

Please sign in to comment.