Skip to content

Commit

Permalink
Merge branch 'hotfix/#736-DBAL-1058-fix-database-and-namespace-intros…
Browse files Browse the repository at this point in the history
…pection-for-sql-server-backport-to-2.5' into 2.5

Close #736
  • Loading branch information
Ocramius committed Jan 12, 2015
2 parents d77aa76 + 4c691fd commit f6ca269
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -1028,15 +1028,15 @@ public function getConcatExpression()
*/
public function getListDatabasesSQL()
{
return 'SELECT * FROM SYS.DATABASES';
return 'SELECT * FROM sys.databases';
}

/**
* {@inheritDoc}
*/
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')";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down

0 comments on commit f6ca269

Please sign in to comment.