Skip to content

Commit

Permalink
bug #54775 [Messenger] accept AbstractAsset instances when filtering …
Browse files Browse the repository at this point in the history
…schemas (xabbuh)

This PR was merged into the 5.4 branch.

Discussion
----------

[Messenger] accept AbstractAsset instances when filtering schemas

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #54769
| License       | MIT

Commits
-------

4d2679d accept AbstractAsset instances when filtering schemas
  • Loading branch information
fabpot committed May 1, 2024
2 parents 6be16ad + 4d2679d commit c1ca4ca
Showing 1 changed file with 12 additions and 1 deletion.
Expand Up @@ -21,6 +21,7 @@
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Query\QueryBuilder;
use Doctrine\DBAL\Result;
use Doctrine\DBAL\Schema\AbstractAsset;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\Schema;
Expand Down Expand Up @@ -289,7 +290,17 @@ public function setup(): void
{
$configuration = $this->driverConnection->getConfiguration();
$assetFilter = $configuration->getSchemaAssetsFilter();
$configuration->setSchemaAssetsFilter(function (string $tableName) { return $tableName === $this->configuration['table_name']; });
$configuration->setSchemaAssetsFilter(function ($tableName) {
if ($tableName instanceof AbstractAsset) {
$tableName = $tableName->getName();
}

if (!\is_string($tableName)) {
throw new \TypeError(sprintf('The table name must be an instance of "%s" or a string ("%s" given).', AbstractAsset::class, get_debug_type($tableName)));
}

return $tableName === $this->configuration['table_name'];
});
$this->updateSchema();
$configuration->setSchemaAssetsFilter($assetFilter);
$this->autoSetup = false;
Expand Down

0 comments on commit c1ca4ca

Please sign in to comment.