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;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Events;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
......@@ -432,8 +433,8 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
public function testQuotedColumnInPrimaryKeyPropagation()
{
$table = new Table('`quoted`');
$table->addColumn('`key`', 'string');
$table->setPrimaryKey(array('key'));
$table->addColumn('create', 'string');
$table->setPrimaryKey(array('create'));
$sql = $this->_platform->getCreateTableSQL($table);
$this->assertEquals($this->getQuotedColumnInPrimaryKeySQL(), $sql);
......@@ -441,19 +442,37 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
abstract protected function getQuotedColumnInPrimaryKeySQL();
abstract protected function getQuotedColumnInIndexSQL();
abstract protected function getQuotedColumnInForeignKeySQL();
/**
* @group DBAL-374
*/
public function testQuotedColumnInIndexPropagation()
{
$this->markTestSkipped('requires big refactoring of Platforms');
$table = new Table('`quoted`');
$table->addColumn('`key`', 'string');
$table->addIndex(array('key'));
$table->addColumn('create', 'string');
$table->addIndex(array('create'));
$sql = $this->_platform->getCreateTableSQL($table);
$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
protected function getQuotedColumnInPrimaryKeySQL()
{
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()
{
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
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()
{
return array(
'CREATE TABLE "quoted" ("key" VARCHAR2(255) NOT NULL)',
'CREATE INDEX IDX_22660D028A90ABA9 ON "quoted" ("key")',
'CREATE TABLE "quoted" ("create" VARCHAR2(255) NOT NULL)',
'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
protected function getQuotedColumnInPrimaryKeySQL()
{
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()
{
return array(
'CREATE TABLE "quoted" ("key" VARCHAR(255) NOT NULL)',
'CREATE INDEX IDX_22660D028A90ABA9 ON "quoted" ("key")',
'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL)',
'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
protected function getQuotedColumnInPrimaryKeySQL()
{
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()
{
return array(
'CREATE TABLE [quoted] ([key] NVARCHAR(255) NOT NULL)',
'CREATE INDEX IDX_22660D028A90ABA9 ON [quoted] ([key])',
'CREATE TABLE [quoted] ([create] NVARCHAR(255) NOT NULL)',
'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
protected function getQuotedColumnInPrimaryKeySQL()
{
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()
{
return array(
'CREATE TABLE "quoted" ("key" VARCHAR(255) NOT NULL)',
'CREATE INDEX IDX_22660D028A90ABA9 ON "quoted" ("key")',
'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL)',
'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