Skip to content

Commit

Permalink
Extend AbstractMySQLPlatform::getColumnTypeSQLSnippets() deprecation …
Browse files Browse the repository at this point in the history
…layer
  • Loading branch information
derrabus committed Nov 5, 2023
1 parent 39fe3b4 commit 4e30b2c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
8 changes: 5 additions & 3 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ awareness about deprecated code.

# Upgrade to 3.8

## Deprecated `AbstractMySQLPlatform::getColumnTypeSQLSnippets()`
## Deprecated `AbstractMySQLPlatform` methods

`AbstractMySQLPlatform::getColumnTypeSQLSnippets()` has been deprecated.
Use `AbstractMySQLPlatform::getColumnTypeSQLSnippet()` instead.
* `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`

Expand Down
1 change: 1 addition & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@
TODO: remove in 4.0.0
-->
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractMySQLPlatform::getColumnTypeSQLSnippets" />
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractMySQLPlatform::getDatabaseNameSQL" />

<!-- TODO for PHPUnit 10 -->
<referencedMethod name="PHPUnit\Framework\MockObject\Builder\InvocationMocker::withConsecutive"/>
Expand Down
8 changes: 8 additions & 0 deletions src/Platforms/AbstractMySQLPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -1422,8 +1422,16 @@ public function supportsColumnLengthIndexes(): bool
return true;
}

/** @deprecated Will be removed without replacement. */
protected function getDatabaseNameSQL(?string $databaseName): string
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'TODO',
'%s is deprecated without replacement.',
__METHOD__,
);

if ($databaseName !== null) {
return $this->quoteStringLiteral($databaseName);
}
Expand Down
11 changes: 11 additions & 0 deletions src/Platforms/MariaDb1043Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Platforms;

use Doctrine\DBAL\Types\JsonType;
use Doctrine\Deprecations\Deprecation;

use function sprintf;

Expand Down Expand Up @@ -81,6 +82,16 @@ public function getColumnTypeSQLSnippet(string $tableAlias = 'c', ?string $datab
return parent::getColumnTypeSQLSnippet($tableAlias, $databaseName);
}

if ($databaseName === null) {
Deprecation::trigger(
'doctrine/dbal',
'TODO',
'Not passing a database name to methods "getColumnTypeSQLSnippet()", '
. '"getColumnTypeSQLSnippets()", and "getListTableColumnsSQL()" of "%s" is deprecated.',
self::class,
);
}

$databaseName = $this->getDatabaseNameSQL($databaseName);

// The check for `CONSTRAINT_SCHEMA = $databaseName` is mandatory here to prevent performance issues
Expand Down

0 comments on commit 4e30b2c

Please sign in to comment.