Unverified Commit 24170d37 authored by Sergei Morozov's avatar Sergei Morozov

Merge branch 'bpo/2.9/#3679' into 2.9

parents a2bfa40b a9b7bf85
...@@ -356,6 +356,8 @@ class Connection implements DriverConnection ...@@ -356,6 +356,8 @@ class Connection implements DriverConnection
$this->_conn = $this->_driver->connect($this->params, $user, $password, $driverOptions); $this->_conn = $this->_driver->connect($this->params, $user, $password, $driverOptions);
$this->isConnected = true; $this->isConnected = true;
$this->transactionNestingLevel = 0;
if ($this->autoCommit === false) { if ($this->autoCommit === false) {
$this->beginTransaction(); $this->beginTransaction();
} }
......
...@@ -69,6 +69,40 @@ class ConnectionTest extends DbalFunctionalTestCase ...@@ -69,6 +69,40 @@ class ConnectionTest extends DbalFunctionalTestCase
$this->connection->rollBack(); $this->connection->rollBack();
self::assertEquals(0, $this->connection->getTransactionNestingLevel()); self::assertEquals(0, $this->connection->getTransactionNestingLevel());
} }
$this->connection->beginTransaction();
$this->connection->close();
$this->connection->beginTransaction();
self::assertEquals(1, $this->connection->getTransactionNestingLevel());
}
public function testTransactionNestingLevelIsResetOnReconnect() : void
{
if ($this->connection->getDatabasePlatform()->getName() === 'sqlite') {
$params = $this->connection->getParams();
$params['memory'] = false;
$params['path'] = '/tmp/test_nesting.sqlite';
$connection = DriverManager::getConnection(
$params,
$this->connection->getConfiguration(),
$this->connection->getEventManager()
);
} else {
$connection = $this->connection;
}
$connection->executeQuery('CREATE TABLE test_nesting(test int not null)');
$this->connection->beginTransaction();
$this->connection->beginTransaction();
$connection->close(); // connection closed in runtime (for example if lost or another application logic)
$connection->beginTransaction();
$connection->executeQuery('insert into test_nesting values (33)');
$connection->rollback();
self::assertEquals(0, $connection->fetchColumn('select count(*) from test_nesting'));
} }
public function testTransactionNestingBehaviorWithSavepoints() public function testTransactionNestingBehaviorWithSavepoints()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment