Closed bendavies closed 11 months ago
Regarding a test: I think this should work? inside the functional PhpunitTest
public function testWillThrowSpecificExceptionOnRollback(): void
{
$this->expectException(\Doctrine\DBAL\Exception\DriverException::class);
$this->connection->beginTransaction();
$this->connection->executeQuery('TRUNCATE TABLE test');
$this->connection->rollBack();
}
@bendavies actually I'm not sure I can reproduce the issue.
I disabled the bundle and ran the test case mentioned above:
There was 1 failure:
1) Tests\Functional\PhpunitTest::testWillThrowSpecificExceptionOnRollback
Failed asserting that exception of type "Doctrine\DBAL\Driver\PDO\PDOException" matches expected exception "Doctrine\DBAL\Exception\DriverException". Message was: "There is no active transaction" at
/var/www/doctrine-test-bundle/vendor/doctrine/dbal/src/Driver/PDO/Connection.php:130
/var/www/doctrine-test-bundle/vendor/doctrine/dbal/src/Driver/Middleware/AbstractConnectionMiddleware.php:86
/var/www/doctrine-test-bundle/vendor/doctrine/dbal/src/Logging/Connection.php:80
/var/www/doctrine-test-bundle/vendor/doctrine/dbal/src/Driver/Middleware/AbstractConnectionMiddleware.php:86
/var/www/doctrine-test-bundle/vendor/symfony/doctrine-bridge/Middleware/Debug/Connection.php:134
/var/www/doctrine-test-bundle/vendor/doctrine/dbal/src/Connection.php:1514
/var/www/doctrine-test-bundle/tests/Functional/PhpunitTest.php:135
its the same exception class that is also thrown when activating the bundle.
Do you have an example where this currently throws the wrong (not converted) exception?
I'll take a look later! Our setup might be a bit funky.
Closing for now. Let me know if there is a way to reproduce the issue
This is sort of a regression from v7, where by exception conversion is lost when creating and releasing savepoints.
This is because the transcations handling for savepoints and exception conversion was previously done in
Doctrine\DBAL\Connection
, but since that's now moved to theStaticConnection
, exception handling needs to be done there.