Skip to content

Commit d5e2a68

Browse files
committed
bug symfony#61583 [DoctrineBridge] Fix exception catch when deleting temporary table in the sameDatabaseChecker (GromNaN)
This PR was merged into the 6.4 branch. Discussion ---------- [DoctrineBridge] Fix exception catch when deleting temporary table in the sameDatabaseChecker | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix symfony#61579 | License | MIT When the sameDatabaseChecker tries to delete a table that doesn't exist on MSSQL, it gets a `DatabaseObjectNotFoundException`, that is a parent error of `TableNotFoundException`. https://github.com/doctrine/dbal/blob/d5a5a2165676e15a1805dc1b43d57c0bec7493bc/src/Exception/TableNotFoundException.php#L10C38-L10C69 The error code is [15151](https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-events-and-errors-15000-to-15999): `Cannot %S_MSG the %S_MSG '%.*ls', because it does not exist or you do not have permission.`. Doctrine DBAL cannot distinguish which object it is: https://github.com/doctrine/dbal/blob/d5a5a2165676e15a1805dc1b43d57c0bec7493bc/src/Driver/API/SQLSrv/ExceptionConverter.php#L43 Commits ------- 261333b Fix exception catch when deleting temporary table in the sameDatabaseChecker
2 parents e6dfb3d + 261333b commit d5e2a68

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Symfony/Bridge/Doctrine/SchemaListener/AbstractSchemaListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Bridge\Doctrine\SchemaListener;
1313

1414
use Doctrine\DBAL\Connection;
15-
use Doctrine\DBAL\Exception\TableNotFoundException;
15+
use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException;
1616
use Doctrine\DBAL\Schema\Table;
1717
use Doctrine\DBAL\Types\Types;
1818
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
@@ -44,7 +44,7 @@ protected function getIsSameDatabaseChecker(Connection $connection): \Closure
4444
$schemaManager->dropTable($checkTable);
4545

4646
return false;
47-
} catch (TableNotFoundException) {
47+
} catch (DatabaseObjectNotFoundException) {
4848
return true;
4949
}
5050
};

0 commit comments

Comments
 (0)