Commit 7ff882fe authored by Steve Müller's avatar Steve Müller

extend platform tests to test quoted column names in index and constraint generation

parent 854fa9b4
...@@ -4,6 +4,7 @@ namespace Doctrine\Tests\DBAL\Platforms; ...@@ -4,6 +4,7 @@ namespace Doctrine\Tests\DBAL\Platforms;
use Doctrine\Common\EventManager; use Doctrine\Common\EventManager;
use Doctrine\DBAL\Events; use Doctrine\DBAL\Events;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Schema\TableDiff;
...@@ -432,8 +433,8 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase ...@@ -432,8 +433,8 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
public function testQuotedColumnInPrimaryKeyPropagation() public function testQuotedColumnInPrimaryKeyPropagation()
{ {
$table = new Table('`quoted`'); $table = new Table('`quoted`');
$table->addColumn('`key`', 'string'); $table->addColumn('create', 'string');
$table->setPrimaryKey(array('key')); $table->setPrimaryKey(array('create'));
$sql = $this->_platform->getCreateTableSQL($table); $sql = $this->_platform->getCreateTableSQL($table);
$this->assertEquals($this->getQuotedColumnInPrimaryKeySQL(), $sql); $this->assertEquals($this->getQuotedColumnInPrimaryKeySQL(), $sql);
...@@ -441,19 +442,37 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase ...@@ -441,19 +442,37 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
abstract protected function getQuotedColumnInPrimaryKeySQL(); abstract protected function getQuotedColumnInPrimaryKeySQL();
abstract protected function getQuotedColumnInIndexSQL(); abstract protected function getQuotedColumnInIndexSQL();
abstract protected function getQuotedColumnInForeignKeySQL();
/** /**
* @group DBAL-374 * @group DBAL-374
*/ */
public function testQuotedColumnInIndexPropagation() public function testQuotedColumnInIndexPropagation()
{ {
$this->markTestSkipped('requires big refactoring of Platforms');
$table = new Table('`quoted`'); $table = new Table('`quoted`');
$table->addColumn('`key`', 'string'); $table->addColumn('create', 'string');
$table->addIndex(array('key')); $table->addIndex(array('create'));
$sql = $this->_platform->getCreateTableSQL($table); $sql = $this->_platform->getCreateTableSQL($table);
$this->assertEquals($this->getQuotedColumnInIndexSQL(), $sql); $this->assertEquals($this->getQuotedColumnInIndexSQL(), $sql);
} }
/**
* @group DBAL-374
*/
public function testQuotedColumnInForeignKeyPropagation()
{
$table = new Table('`quoted`');
$table->addColumn('create', 'string');
$table->addColumn('foo', 'string');
$foreignTable = new Table('foreign');
$foreignTable->addColumn('create', 'string');
$foreignTable->addColumn('bar', 'string');
$table->addForeignKeyConstraint($foreignTable, array('create', 'foo'), array('create', 'bar'));
$sql = $this->_platform->getCreateTableSQL($table, AbstractPlatform::CREATE_FOREIGNKEYS);
$this->assertEquals($this->getQuotedColumnInForeignKeySQL(), $sql);
}
} }
...@@ -237,14 +237,22 @@ class MySqlPlatformTest extends AbstractPlatformTestCase ...@@ -237,14 +237,22 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
protected function getQuotedColumnInPrimaryKeySQL() protected function getQuotedColumnInPrimaryKeySQL()
{ {
return array( return array(
'CREATE TABLE `quoted` (`key` VARCHAR(255) NOT NULL, PRIMARY KEY(`key`)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB' 'CREATE TABLE `quoted` (`create` VARCHAR(255) NOT NULL, PRIMARY KEY(`create`)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
); );
} }
protected function getQuotedColumnInIndexSQL() protected function getQuotedColumnInIndexSQL()
{ {
return array( return array(
'CREATE TABLE `quoted` (`key` VARCHAR(255) NOT NULL, INDEX IDX_22660D028A90ABA9 (`key`)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB' 'CREATE TABLE `quoted` (`create` VARCHAR(255) NOT NULL, INDEX IDX_22660D028FD6E0FB (`create`)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
}
protected function getQuotedColumnInForeignKeySQL()
{
return array(
'CREATE TABLE `quoted` (`create` VARCHAR(255) NOT NULL, foo VARCHAR(255) NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
'ALTER TABLE `quoted` ADD CONSTRAINT FK_22660D028FD6E0FB8C736521 FOREIGN KEY (`create`, foo) REFERENCES `foreign` (`create`, bar)',
); );
} }
......
...@@ -288,14 +288,22 @@ class OraclePlatformTest extends AbstractPlatformTestCase ...@@ -288,14 +288,22 @@ class OraclePlatformTest extends AbstractPlatformTestCase
protected function getQuotedColumnInPrimaryKeySQL() protected function getQuotedColumnInPrimaryKeySQL()
{ {
return array('CREATE TABLE "quoted" ("key" VARCHAR2(255) NOT NULL, PRIMARY KEY("key"))'); return array('CREATE TABLE "quoted" ("create" VARCHAR2(255) NOT NULL, PRIMARY KEY("create"))');
} }
protected function getQuotedColumnInIndexSQL() protected function getQuotedColumnInIndexSQL()
{ {
return array( return array(
'CREATE TABLE "quoted" ("key" VARCHAR2(255) NOT NULL)', 'CREATE TABLE "quoted" ("create" VARCHAR2(255) NOT NULL)',
'CREATE INDEX IDX_22660D028A90ABA9 ON "quoted" ("key")', 'CREATE INDEX IDX_22660D028FD6E0FB ON "quoted" ("create")',
);
}
protected function getQuotedColumnInForeignKeySQL()
{
return array(
'CREATE TABLE "quoted" ("create" VARCHAR2(255) NOT NULL, foo VARCHAR2(255) NOT NULL)',
'ALTER TABLE "quoted" ADD CONSTRAINT FK_22660D028FD6E0FB8C736521 FOREIGN KEY ("create", foo) REFERENCES foreign ("create", bar)',
); );
} }
} }
...@@ -270,15 +270,23 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase ...@@ -270,15 +270,23 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
protected function getQuotedColumnInPrimaryKeySQL() protected function getQuotedColumnInPrimaryKeySQL()
{ {
return array( return array(
'CREATE TABLE "quoted" ("key" VARCHAR(255) NOT NULL, PRIMARY KEY("key"))', 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, PRIMARY KEY("create"))',
); );
} }
protected function getQuotedColumnInIndexSQL() protected function getQuotedColumnInIndexSQL()
{ {
return array( return array(
'CREATE TABLE "quoted" ("key" VARCHAR(255) NOT NULL)', 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL)',
'CREATE INDEX IDX_22660D028A90ABA9 ON "quoted" ("key")', 'CREATE INDEX IDX_22660D028FD6E0FB ON "quoted" ("create")',
);
}
protected function getQuotedColumnInForeignKeySQL()
{
return array(
'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, foo VARCHAR(255) NOT NULL)',
'ALTER TABLE "quoted" ADD CONSTRAINT FK_22660D028FD6E0FB8C736521 FOREIGN KEY ("create", foo) REFERENCES "foreign" ("create", bar) NOT DEFERRABLE INITIALLY IMMEDIATE',
); );
} }
......
...@@ -296,15 +296,23 @@ class SQLServerPlatformTest extends AbstractPlatformTestCase ...@@ -296,15 +296,23 @@ class SQLServerPlatformTest extends AbstractPlatformTestCase
protected function getQuotedColumnInPrimaryKeySQL() protected function getQuotedColumnInPrimaryKeySQL()
{ {
return array( return array(
'CREATE TABLE [quoted] ([key] NVARCHAR(255) NOT NULL, PRIMARY KEY ([key]))', 'CREATE TABLE [quoted] ([create] NVARCHAR(255) NOT NULL, PRIMARY KEY ([create]))',
); );
} }
protected function getQuotedColumnInIndexSQL() protected function getQuotedColumnInIndexSQL()
{ {
return array( return array(
'CREATE TABLE [quoted] ([key] NVARCHAR(255) NOT NULL)', 'CREATE TABLE [quoted] ([create] NVARCHAR(255) NOT NULL)',
'CREATE INDEX IDX_22660D028A90ABA9 ON [quoted] ([key])', 'CREATE INDEX IDX_22660D028FD6E0FB ON [quoted] ([create])',
);
}
protected function getQuotedColumnInForeignKeySQL()
{
return array(
'CREATE TABLE [quoted] ([create] NVARCHAR(255) NOT NULL, foo NVARCHAR(255) NOT NULL)',
'ALTER TABLE [quoted] ADD CONSTRAINT FK_22660D028FD6E0FB8C736521 FOREIGN KEY ([create], foo) REFERENCES [foreign] ([create], bar)',
); );
} }
} }
...@@ -280,15 +280,22 @@ class SqlitePlatformTest extends AbstractPlatformTestCase ...@@ -280,15 +280,22 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
protected function getQuotedColumnInPrimaryKeySQL() protected function getQuotedColumnInPrimaryKeySQL()
{ {
return array( return array(
'CREATE TABLE "quoted" ("key" VARCHAR(255) NOT NULL, PRIMARY KEY("key"))', 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, PRIMARY KEY("create"))',
); );
} }
protected function getQuotedColumnInIndexSQL() protected function getQuotedColumnInIndexSQL()
{ {
return array( return array(
'CREATE TABLE "quoted" ("key" VARCHAR(255) NOT NULL)', 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL)',
'CREATE INDEX IDX_22660D028A90ABA9 ON "quoted" ("key")', 'CREATE INDEX IDX_22660D028FD6E0FB ON "quoted" ("create")',
);
}
protected function getQuotedColumnInForeignKeySQL()
{
return array(
'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, foo VARCHAR(255) NOT NULL, CONSTRAINT FK_22660D028FD6E0FB8C736521 FOREIGN KEY ("create", foo) REFERENCES "foreign" ("create", bar) NOT DEFERRABLE INITIALLY IMMEDIATE)',
); );
} }
} }
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