Commit d94345d3 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Backport testcase to verify behavior is correct.

parent 8f4709bc
......@@ -12,65 +12,81 @@ class TemporaryTableTest extends \Doctrine\Tests\DbalFunctionalTestCase
{
parent::setUp();
try {
$this->_conn->exec($this->_conn->getDatabasePlatform()->getDropTableSQL("non_temporary"));
$this->_conn->exec($this->_conn->getDatabasePlatform()->getDropTableSQL("nontemporary"));
} catch(\Exception $e) {
}
}
public function tearDown()
{
if ($this->_conn) {
try {
$tempTable = $this->_conn->getDatabasePlatform()->getTemporaryTableName("temporary");
$this->_conn->exec($this->_conn->getDatabasePlatform()->getDropTemporaryTableSQL($tempTable));
} catch(\Exception $e) { }
}
}
/**
* @group DDC-1337
* @return void
*/
public function testDropTemporaryTableNotAbortsTransaction()
public function testDropTemporaryTableNotAutoCommitTransaction()
{
$platform = $this->_conn->getDatabasePlatform();
$columnDefinitions = array("id" => array("type" => Type::getType("integer"), "notnull" => true));
$tempTable = $platform->getTemporaryTableName("temporary");
$tempTableSQL = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' ('
$createTempTableSQL = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' ('
. $platform->getColumnDeclarationListSQL($columnDefinitions) . ')';
$this->_conn->executeUpdate($createTempTableSQL);
$table = new Table("non_temporary");
$table = new Table("nontemporary");
$table->addColumn("id", "integer");
$table->setPrimaryKey(array('id'));
$this->_conn->getSchemaManager()->createTable($table);
$this->_conn->beginTransaction();
$this->_conn->insert("non_temporary", array("id" => 1));
foreach ($platform->getCreateTableSQL($table) AS $sql) {
$this->_conn->executeQuery($sql);
}
$this->_conn->exec($tempTableSQL);
$this->_conn->beginTransaction();
$this->_conn->insert("nontemporary", array("id" => 1));
$this->_conn->exec($platform->getDropTemporaryTableSQL($tempTable));
$this->_conn->insert("non_temporary", array("id" => 2));
$this->_conn->insert("nontemporary", array("id" => 2));
$this->_conn->rollback();
$rows = $this->_conn->fetchAll('SELECT * FROM non_temporary');
$this->assertEquals(array(), $rows);
$rows = $this->_conn->fetchAll('SELECT * FROM nontemporary');
$this->assertEquals(array(), $rows, "In an event of an error this result has one row, because of an implicit commit.");
}
/**
* @group DDC-1337
* @return void
*/
public function testCreateTemporaryTableNotAbortsTransaction()
public function testCreateTemporaryTableNotAutoCommitTransaction()
{
$platform = $this->_conn->getDatabasePlatform();
$columnDefinitions = array("id" => array("type" => Type::getType("integer"), "notnull" => true));
$tempTable = $platform->getTemporaryTableName("temporary");
$tempTableSQL = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' ('
$createTempTableSQL = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' ('
. $platform->getColumnDeclarationListSQL($columnDefinitions) . ')';
$table = new Table("non_temporary");
$table = new Table("nontemporary");
$table->addColumn("id", "integer");
$table->setPrimaryKey(array('id'));
foreach ($platform->getCreateTableSQL($table) AS $sql) {
$this->_conn->executeQuery($sql);
}
$this->_conn->getSchemaManager()->createTable($table);
$this->_conn->beginTransaction();
$this->_conn->insert("non_temporary", array("id" => 1));
$this->_conn->insert("nontemporary", array("id" => 1));
$this->_conn->exec($tempTableSQL);
$this->_conn->insert("non_temporary", array("id" => 2));
$this->_conn->exec($createTempTableSQL);
$this->_conn->insert("nontemporary", array("id" => 2));
$this->_conn->rollback();
......@@ -80,7 +96,7 @@ class TemporaryTableTest extends \Doctrine\Tests\DbalFunctionalTestCase
}
$rows = $this->_conn->fetchAll('SELECT * FROM non_temporary');
$this->assertEquals(array(), $rows);
$rows = $this->_conn->fetchAll('SELECT * FROM nontemporary');
$this->assertEquals(array(), $rows, "In an event of an error this result has one row, because of an implicit commit.");
}
}
\ No newline at end of file
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