diff --git a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php index e41ceb27b40..4fc28b815f1 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php @@ -1028,7 +1028,7 @@ public function getConcatExpression() */ public function getListDatabasesSQL() { - return 'SELECT * FROM SYS.DATABASES'; + return 'SELECT * FROM sys.databases'; } /** @@ -1036,7 +1036,7 @@ public function getListDatabasesSQL() */ public function getListNamespacesSQL() { - return "SELECT name FROM SYS.SCHEMAS WHERE name NOT IN('guest', 'INFORMATION_SCHEMA', 'sys')"; + return "SELECT name FROM sys.schemas WHERE name NOT IN('guest', 'INFORMATION_SCHEMA', 'sys')"; } /** diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php index 50cf07cb626..2877c5fabec 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php @@ -95,6 +95,29 @@ public function testListDatabases() $this->assertContains('test_create_database', $databases); } + /** + * @group DBAL-1058 + */ + public function testListNamespaceNames() + { + if (!$this->_sm->getDatabasePlatform()->supportsSchemas()) { + $this->markTestSkipped('Platform does not support schemas.'); + } + + // Currently dropping schemas is not supported, so we have to workaround here. + $namespaces = $this->_sm->listNamespaceNames(); + $namespaces = array_map('strtolower', $namespaces); + + if (!in_array('test_create_schema', $namespaces)) { + $this->_conn->executeUpdate($this->_sm->getDatabasePlatform()->getCreateSchemaSQL('test_create_schema')); + + $namespaces = $this->_sm->listNamespaceNames(); + $namespaces = array_map('strtolower', $namespaces); + } + + $this->assertContains('test_create_schema', $namespaces); + } + public function testListTables() { $this->createTestTable('list_tables_test'); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php index df0e635e0e8..cc59e4a72a2 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php @@ -81,7 +81,7 @@ public function testGeneratesDDLSnippets() { $dropDatabaseExpectation = 'DROP DATABASE foobar'; - $this->assertEquals('SELECT * FROM SYS.DATABASES', $this->_platform->getListDatabasesSQL()); + $this->assertEquals('SELECT * FROM sys.databases', $this->_platform->getListDatabasesSQL()); $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar')); $this->assertEquals($dropDatabaseExpectation, $this->_platform->getDropDatabaseSQL('foobar')); $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar'));