Skip to content

Commit

Permalink
Add test case for transactional DDL
Browse files Browse the repository at this point in the history
Based on conversation at #4481 it's undesired that consumer should have capabilities to know if they can or cannot run transaction on given DDL. This commit demonstrates that this problem is present in DBAL too and it doesn't handle the case seamlessly. If consumer is not allowed to know if database allows transactional DDL, DBAL should handle attempts to execute DDL within transaction for databases not supporting transactional DDL seamlessly.
  • Loading branch information
ostrolucky committed Mar 11, 2021
1 parent 70ab840 commit 2a13643
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Doctrine\Tests\DbalFunctionalTestCase;
use Error;
Expand Down Expand Up @@ -283,6 +286,18 @@ public function testTransactionalReturnValue(): void
self::assertEquals(42, $res);
}

public function testTransactionalDDL(): void
{
$this->connection->transactional(static function (Connection $conn): void {
$table = new Table('foo', [new Column('bar', Type::getType('string'))]);
foreach ($conn->getDatabasePlatform()->getCreateTableSQL($table) as $sql) {
$conn->executeStatement($sql);
}
});

self::assertTrue($this->connection->getSchemaManager()->tablesExist('foo'));
}

/**
* Tests that the quote function accepts DBAL and PDO types.
*/
Expand Down

0 comments on commit 2a13643

Please sign in to comment.