Commit 00f9575d authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge remote-tracking branch 'origin/2.3' into 2.3

parents f57250d1 f63af194
......@@ -1165,7 +1165,10 @@ abstract class AbstractPlatform
foreach ($table->getIndexes() as $index) {
/* @var $index Index */
if ($index->isPrimary()) {
$options['primary'] = $index->getColumns();
$platform = $this;
$options['primary'] = array_map(function ($columnName) use ($table, $platform) {
return $table->getColumn($columnName)->getQuotedName($platform);
}, $index->getColumns());
$options['primary_index'] = $index;
} else {
$options['indexes'][$index->getName()] = $index;
......
......@@ -36,7 +36,7 @@ class Version
/**
* Current Doctrine Version
*/
const VERSION = '2.3.1-DEV';
const VERSION = '2.3.2-DEV';
/**
* Compares a Doctrine version with the current one.
......
......@@ -4,6 +4,8 @@ namespace Doctrine\Tests\DBAL\Platforms;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Events;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
{
......@@ -75,7 +77,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
public function testCreateWithNoColumns()
{
$table = new \Doctrine\DBAL\Schema\Table('test');
$table = new Table('test');
$this->setExpectedException('Doctrine\DBAL\DBALException');
$sql = $this->_platform->getCreateTableSQL($table);
......@@ -83,7 +85,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
public function testGeneratesTableCreationSql()
{
$table = new \Doctrine\DBAL\Schema\Table('test');
$table = new Table('test');
$table->addColumn('id', 'integer', array('notnull' => true, 'autoincrement' => true));
$table->addColumn('test', 'string', array('notnull' => false, 'length' => 255));
$table->setPrimaryKey(array('id'));
......@@ -96,7 +98,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
public function testGenerateTableWithMultiColumnUniqueIndex()
{
$table = new \Doctrine\DBAL\Schema\Table('test');
$table = new Table('test');
$table->addColumn('foo', 'string', array('notnull' => false, 'length' => 255));
$table->addColumn('bar', 'string', array('notnull' => false, 'length' => 255));
$table->addUniqueIndex(array("foo", "bar"));
......@@ -203,7 +205,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
{
$expectedSql = $this->getGenerateAlterTableSql();
$tableDiff = new \Doctrine\DBAL\Schema\TableDiff('mytable');
$tableDiff = new TableDiff('mytable');
$tableDiff->newName = 'userlist';
$tableDiff->addedColumns['quota'] = new \Doctrine\DBAL\Schema\Column('quota', \Doctrine\DBAL\Types\Type::getType('integer'), array('notnull' => false));
$tableDiff->removedColumns['foo'] = new \Doctrine\DBAL\Schema\Column('foo', \Doctrine\DBAL\Types\Type::getType('integer'));
......@@ -246,7 +248,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$this->_platform->setEventManager($eventManager);
$table = new \Doctrine\DBAL\Schema\Table('test');
$table = new Table('test');
$table->addColumn('foo', 'string', array('notnull' => false, 'length' => 255));
$table->addColumn('bar', 'string', array('notnull' => false, 'length' => 255));
......@@ -307,7 +309,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$this->_platform->setEventManager($eventManager);
$tableDiff = new \Doctrine\DBAL\Schema\TableDiff('mytable');
$tableDiff = new TableDiff('mytable');
$tableDiff->addedColumns['added'] = new \Doctrine\DBAL\Schema\Column('added', \Doctrine\DBAL\Types\Type::getType('integer'), array());
$tableDiff->removedColumns['removed'] = new \Doctrine\DBAL\Schema\Column('removed', \Doctrine\DBAL\Types\Type::getType('integer'), array());
$tableDiff->changedColumns['changed'] = new \Doctrine\DBAL\Schema\ColumnDiff(
......@@ -326,7 +328,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
*/
public function testCreateTableColumnComments()
{
$table = new \Doctrine\DBAL\Schema\Table('test');
$table = new Table('test');
$table->addColumn('id', 'integer', array('comment' => 'This is a comment'));
$table->setPrimaryKey(array('id'));
......@@ -338,7 +340,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
*/
public function testAlterTableColumnComments()
{
$tableDiff = new \Doctrine\DBAL\Schema\TableDiff('mytable');
$tableDiff = new TableDiff('mytable');
$tableDiff->addedColumns['quota'] = new \Doctrine\DBAL\Schema\Column('quota', \Doctrine\DBAL\Types\Type::getType('integer'), array('comment' => 'A comment'));
$tableDiff->changedColumns['bar'] = new \Doctrine\DBAL\Schema\ColumnDiff(
'bar', new \Doctrine\DBAL\Schema\Column(
......@@ -352,7 +354,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
public function testCreateTableColumnTypeComments()
{
$table = new \Doctrine\DBAL\Schema\Table('test');
$table = new Table('test');
$table->addColumn('id', 'integer');
$table->addColumn('data', 'array');
$table->setPrimaryKey(array('id'));
......@@ -385,4 +387,35 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$this->assertTrue($keywordList->isKeyword('table'));
}
/**
* @group DBAL-374
*/
public function testQuotedColumnInPrimaryKeyPropagation()
{
$table = new Table('`quoted`');
$table->addColumn('`key`', 'string');
$table->setPrimaryKey(array('key'));
$sql = $this->_platform->getCreateTableSQL($table);
$this->assertEquals($this->getQuotedColumnInPrimaryKeySQL(), $sql);
}
abstract protected function getQuotedColumnInPrimaryKeySQL();
abstract protected function getQuotedColumnInIndexSQL();
/**
* @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'));
$sql = $this->_platform->getCreateTableSQL($table);
$this->assertEquals($this->getQuotedColumnInIndexSQL(), $sql);
}
}
......@@ -226,4 +226,18 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
$sql = $this->_platform->getAlterTableSQL($diff);
$this->assertEquals(array("ALTER TABLE test DROP INDEX uniq, ADD INDEX idx (col)"), $sql);
}
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'
);
}
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'
);
}
}
......@@ -269,4 +269,17 @@ class OraclePlatformTest extends AbstractPlatformTestCase
$this->getBitAndComparisonExpressionSql($value1, $value2)
. '+' . $value2 . ')';
}
protected function getQuotedColumnInPrimaryKeySQL()
{
return array('CREATE TABLE "quoted" ("key" VARCHAR2(255) NOT NULL, PRIMARY KEY("key"))');
}
protected function getQuotedColumnInIndexSQL()
{
return array(
'CREATE TABLE "quoted" ("key" VARCHAR2(255) NOT NULL)',
'CREATE INDEX IDX_22660D028A90ABA9 ON "quoted" ("key")',
);
}
}
......@@ -225,4 +225,19 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
"COMMENT ON COLUMN test.data IS '(DC2Type:array)'"
);
}
protected function getQuotedColumnInPrimaryKeySQL()
{
return array(
'CREATE TABLE "quoted" ("key" VARCHAR(255) NOT NULL, PRIMARY KEY("key"))',
);
}
protected function getQuotedColumnInIndexSQL()
{
return array(
'CREATE TABLE "quoted" ("key" VARCHAR(255) NOT NULL)',
'CREATE INDEX IDX_22660D028A90ABA9 ON "quoted" ("key")',
);
}
}
......@@ -227,4 +227,19 @@ class SQLServerPlatformTest extends AbstractPlatformTestCase
$idx = new \Doctrine\DBAL\Schema\Index('idx', array('id'), false, true);
$this->assertEquals('ALTER TABLE tbl ADD PRIMARY KEY (id)', $this->_platform->getCreateIndexSQL($idx, 'tbl'));
}
protected function getQuotedColumnInPrimaryKeySQL()
{
return array(
'CREATE TABLE [quoted] ([key] NVARCHAR(255) NOT NULL, PRIMARY KEY ([key]))',
);
}
protected function getQuotedColumnInIndexSQL()
{
return array(
'CREATE TABLE [quoted] ([key] NVARCHAR(255) NOT NULL)',
'CREATE INDEX IDX_22660D028A90ABA9 ON [quoted] ([key])',
);
}
}
......@@ -152,4 +152,19 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
$this->_platform->getCreatePrimaryKeySQL($table->getIndex('primary'), 'test')
);
}
}
\ No newline at end of file
protected function getQuotedColumnInPrimaryKeySQL()
{
return array(
'CREATE TABLE "quoted" ("key" VARCHAR(255) NOT NULL, PRIMARY KEY("key"))',
);
}
protected function getQuotedColumnInIndexSQL()
{
return array(
'CREATE TABLE "quoted" ("key" VARCHAR(255) NOT NULL)',
'CREATE INDEX IDX_22660D028A90ABA9 ON "quoted" ("key")',
);
}
}
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