Commit 8b848eac authored by Marco Pivetta's avatar Marco Pivetta

Merge pull request #773 from deeky666/fix-sqlanywhere-create-drop-database-sql

[DBAL-1115] Fix quoted identifiers for database creation SQL on SQL Anywhere
parents e6a50d8f 69d563f7
...@@ -405,7 +405,9 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -405,7 +405,9 @@ class SQLAnywherePlatform extends AbstractPlatform
*/ */
public function getCreateDatabaseSQL($database) public function getCreateDatabaseSQL($database)
{ {
return "CREATE DATABASE '$database'"; $database = new Identifier($database);
return "CREATE DATABASE '" . $database->getName() . "'";
} }
/** /**
...@@ -537,7 +539,9 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -537,7 +539,9 @@ class SQLAnywherePlatform extends AbstractPlatform
*/ */
public function getDropDatabaseSQL($database) public function getDropDatabaseSQL($database)
{ {
return "DROP DATABASE '$database'"; $database = new Identifier($database);
return "DROP DATABASE '" . $database->getName() . "'";
} }
/** /**
...@@ -1025,7 +1029,9 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -1025,7 +1029,9 @@ class SQLAnywherePlatform extends AbstractPlatform
*/ */
public function getStartDatabaseSQL($database) public function getStartDatabaseSQL($database)
{ {
return "START DATABASE '$database' AUTOSTOP OFF"; $database = new Identifier($database);
return "START DATABASE '" . $database->getName() . "' AUTOSTOP OFF";
} }
/** /**
...@@ -1042,7 +1048,9 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -1042,7 +1048,9 @@ class SQLAnywherePlatform extends AbstractPlatform
*/ */
public function getStopDatabaseSQL($database) public function getStopDatabaseSQL($database)
{ {
return 'STOP DATABASE "' . $database . '" UNCONDITIONALLY'; $database = new Identifier($database);
return 'STOP DATABASE "' . $database->getName() . '" UNCONDITIONALLY';
} }
/** /**
......
...@@ -301,10 +301,18 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase ...@@ -301,10 +301,18 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
public function testGeneratesDDLSnippets() public function testGeneratesDDLSnippets()
{ {
$this->assertEquals("CREATE DATABASE 'foobar'", $this->_platform->getCreateDatabaseSQL('foobar')); $this->assertEquals("CREATE DATABASE 'foobar'", $this->_platform->getCreateDatabaseSQL('foobar'));
$this->assertEquals("CREATE DATABASE 'foobar'", $this->_platform->getCreateDatabaseSQL('"foobar"'));
$this->assertEquals("CREATE DATABASE 'create'", $this->_platform->getCreateDatabaseSQL('create'));
$this->assertEquals("DROP DATABASE 'foobar'", $this->_platform->getDropDatabaseSQL('foobar')); $this->assertEquals("DROP DATABASE 'foobar'", $this->_platform->getDropDatabaseSQL('foobar'));
$this->assertEquals("DROP DATABASE 'foobar'", $this->_platform->getDropDatabaseSQL('"foobar"'));
$this->assertEquals("DROP DATABASE 'create'", $this->_platform->getDropDatabaseSQL('create'));
$this->assertEquals('CREATE GLOBAL TEMPORARY TABLE', $this->_platform->getCreateTemporaryTableSnippetSQL()); $this->assertEquals('CREATE GLOBAL TEMPORARY TABLE', $this->_platform->getCreateTemporaryTableSnippetSQL());
$this->assertEquals("START DATABASE 'foobar' AUTOSTOP OFF", $this->_platform->getStartDatabaseSQL('foobar')); $this->assertEquals("START DATABASE 'foobar' AUTOSTOP OFF", $this->_platform->getStartDatabaseSQL('foobar'));
$this->assertEquals("START DATABASE 'foobar' AUTOSTOP OFF", $this->_platform->getStartDatabaseSQL('"foobar"'));
$this->assertEquals("START DATABASE 'create' AUTOSTOP OFF", $this->_platform->getStartDatabaseSQL('create'));
$this->assertEquals('STOP DATABASE "foobar" UNCONDITIONALLY', $this->_platform->getStopDatabaseSQL('foobar')); $this->assertEquals('STOP DATABASE "foobar" UNCONDITIONALLY', $this->_platform->getStopDatabaseSQL('foobar'));
$this->assertEquals('STOP DATABASE "foobar" UNCONDITIONALLY', $this->_platform->getStopDatabaseSQL('"foobar"'));
$this->assertEquals('STOP DATABASE "create" UNCONDITIONALLY', $this->_platform->getStopDatabaseSQL('create'));
$this->assertEquals('TRUNCATE TABLE foobar', $this->_platform->getTruncateTableSQL('foobar')); $this->assertEquals('TRUNCATE TABLE foobar', $this->_platform->getTruncateTableSQL('foobar'));
$this->assertEquals('TRUNCATE TABLE foobar', $this->_platform->getTruncateTableSQL('foobar'), true); $this->assertEquals('TRUNCATE TABLE foobar', $this->_platform->getTruncateTableSQL('foobar'), true);
......
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