Skip to content
Browse files

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.
  • Loading branch information...
1 parent 03d7a9e commit 3d55dc8eec235c09d64b061456295a1951299496 @beberlei beberlei committed
View
1 lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
@@ -96,7 +96,6 @@ public function getDropDatabaseSQL($name)
SET SINGLE_USER --or RESTRICTED_USER
WITH ROLLBACK IMMEDIATE;
DROP DATABASE ' . $name . ';';
- return 'DROP DATABASE ' . $name;
}
/**
View
2 lib/Doctrine/DBAL/Schema/Index.php
@@ -115,7 +115,7 @@ public function spansColumns(array $columnNames)
{
$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;
}
}
View
6 lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php
@@ -137,10 +137,6 @@ public function clearQueries()
*/
public function getQueries()
{
- return array_merge(
- $this->_constraints,
- $this->_sequences,
- $this->_tables
- );
+ return array_merge($this->_constraints, $this->_tables, $this->_sequences);
}
}
View
3 tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
@@ -231,7 +231,8 @@ public function testCreateTableWithForeignKeys()
$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()
View
9 tests/Doctrine/Tests/DBAL/Platforms/MsSqlPlatformTest.php
@@ -66,9 +66,16 @@ public function testGeneratesTransactionsCommands()
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'));
}
View
2 tests/Doctrine/Tests/DBAL/Schema/TableTest.php
@@ -326,7 +326,7 @@ public function testAddIndexWithCaseSensitiveColumnProblem()
$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()
View
2 tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php
@@ -53,7 +53,7 @@ public function testDropSchema()
$sql = $schema->toDropSql($platformMock);
- $this->assertEquals(array("fk", "seq", "tbl", "tbl"), $sql);
+ $this->assertEquals(array("fk", "tbl", "tbl", "seq"), $sql);
}
/**

0 comments on commit 3d55dc8

Please sign in to comment.
Something went wrong with that request. Please try again.