Commit 3d55dc8e authored by Benjamin Eberlei's avatar Benjamin Eberlei

DBAL-54 - Fix sequence drop executed before tables, however sequences mostly...

DBAL-54 - Fix sequence drop executed before tables, however sequences mostly depend on tables. Also clean up several test-failures on MSSQL tests and  Oracle Index detection.
parent 03d7a9e0
......@@ -96,7 +96,6 @@ class MsSqlPlatform extends AbstractPlatform
SET SINGLE_USER --or RESTRICTED_USER
WITH ROLLBACK IMMEDIATE;
DROP DATABASE ' . $name . ';';
return 'DROP DATABASE ' . $name;
}
/**
......
......@@ -115,7 +115,7 @@ class Index extends AbstractAsset implements Constraint
{
$sameColumns = true;
for ($i = 0; $i < count($this->_columns); $i++) {
if (!isset($columnNames[$i]) || $this->_columns[$i] != $columnNames[$i]) {
if (!isset($columnNames[$i]) || strtolower($this->_columns[$i]) != strtolower($columnNames[$i])) {
$sameColumns = false;
}
}
......
......@@ -137,10 +137,6 @@ class DropSchemaSqlCollector implements Visitor
*/
public function getQueries()
{
return array_merge(
$this->_constraints,
$this->_sequences,
$this->_tables
);
return array_merge($this->_constraints, $this->_tables, $this->_sequences);
}
}
......@@ -231,7 +231,8 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$this->assertEquals('test_foreign', strtolower($fkConstraint->getForeignTableName()));
$this->assertEquals(array('foreign_key_test'), array_map('strtolower', $fkConstraint->getColumns()));
$this->assertEquals(array('id'), array_map('strtolower', $fkConstraint->getForeignColumns()));
$this->assertTrue($fkTable->columnsAreIndexed($fkConstraint->getColumns()));
$this->assertTrue($fkTable->columnsAreIndexed($fkConstraint->getColumns()), "The columns of a foreign key constraint should always be indexed.");
}
public function testListForeignKeys()
......
......@@ -66,9 +66,16 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase
public function testGeneratesDDLSnippets()
{
$dropDatabaseExpectation = <<<DDB
ALTER DATABASE [foobar]
SET SINGLE_USER --or RESTRICTED_USER
WITH ROLLBACK IMMEDIATE;
DROP DATABASE foobar;
DDB;
$this->assertEquals('SHOW DATABASES', $this->_platform->getShowDatabasesSQL());
$this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar'));
$this->assertEquals('DROP DATABASE foobar', $this->_platform->getDropDatabaseSQL('foobar'));
$this->assertEquals($dropDatabaseExpectation, $this->_platform->getDropDatabaseSQL('foobar'));
$this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar'));
}
......
......@@ -326,7 +326,7 @@ class TableTest extends \PHPUnit_Framework_TestCase
$table->addIndex(array("ID"), "my_idx");
$this->assertTrue($table->hasIndex('my_idx'));
$this->assertEquals(array("ID"), $table->getIndex("my_idx")->getColumns());
$this->assertEquals(array("id"), $table->getIndex("my_idx")->getColumns());
}
public function testAddPrimaryKey_ColumnsAreExplicitlySetToNotNull()
......
......@@ -53,7 +53,7 @@ class SchemaSqlCollectorTest extends \PHPUnit_Framework_TestCase
$sql = $schema->toDropSql($platformMock);
$this->assertEquals(array("fk", "seq", "tbl", "tbl"), $sql);
$this->assertEquals(array("fk", "tbl", "tbl", "seq"), $sql);
}
/**
......
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