Skip to content

Commit

Permalink
Deprecate AbstractAsset::getFullQualifiedName()
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Sep 26, 2021
1 parent 5e3c4c5 commit f0faabd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
5 changes: 5 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ awareness about deprecated code.

# Upgrade to 3.2

## Deprecated `AbstractAsset::getFullQualifiedName()`.

The `AbstractAsset::getFullQualifiedName()` method has been deprecated. Use `::getNamespaceName()`
and `::getName()` instead.

## Deprecated `AbstractPlatform::canEmulateSchemas()`.

The `AbstractPlatform::canEmulateSchemas()` method and the schema emulation implemented in the SQLite platform
Expand Down
5 changes: 5 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@
TODO: remove in 4.0.0
-->
<referencedMethod name="Doctrine\DBAL\Platforms\OraclePlatform::assertValidIdentifier"/>
<!--
TODO: remove in 4.0.0
See https://github.com/doctrine/dbal/pull/4814
-->
<referencedMethod name="Doctrine\DBAL\Schema\AbstractAsset::getFullQualifiedName"/>
</errorLevel>
</DeprecatedMethod>
<DeprecatedProperty>
Expand Down
12 changes: 11 additions & 1 deletion src/Schema/AbstractAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Schema;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\Deprecations\Deprecation;

use function array_map;
use function crc32;
Expand Down Expand Up @@ -102,20 +103,29 @@ public function getShortestName($defaultNamespaceName)
}

/**
* The normalized name is full-qualified and lowerspaced. Lowerspacing is
* The normalized name is full-qualified and lower-cased. Lower-casing is
* actually wrong, but we have to do it to keep our sanity. If you are
* using database objects that only differentiate in the casing (FOO vs
* Foo) then you will NOT be able to use Doctrine Schema abstraction.
*
* Every non-namespaced element is prefixed with the default namespace
* name which is passed as argument to this method.
*
* @deprecated Use {@link getNamespaceName()} and {@link getName()} instead.
*
* @param string $defaultNamespaceName
*
* @return string
*/
public function getFullQualifiedName($defaultNamespaceName)
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/4814',
'AbstractAsset::getFullQualifiedName() is deprecated.'
. ' Use AbstractAsset::getNamespaceName() and ::getName() instead.'
);

$name = $this->getName();
if ($this->_namespace === null) {
$name = $defaultNamespaceName . '.' . $name;
Expand Down
9 changes: 7 additions & 2 deletions src/Schema/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function hasExplicitForeignKeyIndexes()
protected function _addTable(Table $table)
{
$namespaceName = $table->getNamespaceName();
$tableName = $table->getFullQualifiedName($this->getName());
$tableName = $this->normalizeName($table);

if (isset($this->_tables[$tableName])) {
throw SchemaException::tableAlreadyExists($tableName);
Expand All @@ -129,7 +129,7 @@ protected function _addTable(Table $table)
protected function _addSequence(Sequence $sequence)
{
$namespaceName = $sequence->getNamespaceName();
$seqName = $sequence->getFullQualifiedName($this->getName());
$seqName = $this->normalizeName($sequence);

if (isset($this->_sequences[$seqName])) {
throw SchemaException::sequenceAlreadyExists($seqName);
Expand Down Expand Up @@ -199,6 +199,11 @@ private function getFullQualifiedAssetName($name)
return strtolower($name);
}

private function normalizeName(AbstractAsset $asset): string
{
return $asset->getFullQualifiedName($this->getName());
}

/**
* Returns the unquoted representation of a given asset name.
*
Expand Down

0 comments on commit f0faabd

Please sign in to comment.