diff --git a/UPGRADE.md b/UPGRADE.md index dab5b16032b..5396a313e35 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -8,6 +8,13 @@ awareness about deprecated code. # Upgrade to 3.4 +# Deprecated `Type::getName()` + +This will method is not useful for the DBAL anymore, and will be removed in 4.0. +As a consequence, depending on the name of a type being `json` for `jsonb` to +be used for the Postgres platform is deprecated in favor of extending +`Doctrine\DBAL\Types\JsonType`. + # Deprecated `AbstractPlatform::getColumnComment()` and `AbstractPlatform::getDoctrineTypeComment()` DBAL no longer needs column comments to ensure proper diffing. Note that both diff --git a/src/Schema/PostgreSQLSchemaManager.php b/src/Schema/PostgreSQLSchemaManager.php index 03239bde5c2..bad1690ccad 100644 --- a/src/Schema/PostgreSQLSchemaManager.php +++ b/src/Schema/PostgreSQLSchemaManager.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\PostgreSQLPlatform; +use Doctrine\DBAL\Types\JsonType; use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; use Doctrine\Deprecations\Deprecation; @@ -15,6 +16,7 @@ use function array_shift; use function assert; use function explode; +use function get_class; use function implode; use function in_array; use function preg_match; @@ -530,6 +532,17 @@ protected function _getPortableTableColumnDefinition($tableColumn) } if ($column->getType()->getName() === Types::JSON) { + if (! $column->getType() instanceof JsonType) { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/5049', + '%s not extending %s while being named %s is deprecated, and will lead to jsonb never to being used in 4.0.', + get_class($column->getType()), + JsonType::class, + Types::JSON + ); + } + $column->setPlatformOption('jsonb', $jsonb); } diff --git a/src/Types/Type.php b/src/Types/Type.php index c2ae2be5ad4..f9fc6d0827e 100644 --- a/src/Types/Type.php +++ b/src/Types/Type.php @@ -102,9 +102,9 @@ abstract public function getSQLDeclaration(array $column, AbstractPlatform $plat /** * Gets the name of this type. * - * @return string + * @deprecated this method will be removed in Doctrine DBAL 4.0. * - * @todo Needed? + * @return string */ abstract public function getName();