Commit b4f2b77b authored by Vincent Petry's avatar Vincent Petry

Added unit test for changing column lengths

Unit tests currently only cover SQLite, MySQL and PostgreSQL.

Tests for other platforms have been marked as incomplete.
parent f8c1d77e
......@@ -580,4 +580,20 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
"CHANGE quoted3 `baz` INT NOT NULL COMMENT 'Quoted 3'"
);
}
/**
* {@inheritdoc}
*/
protected function getQuotedAlterTableChangeColumnLengthSQL()
{
return array(
"ALTER TABLE mytable " .
"CHANGE unquoted1 unquoted1 VARCHAR(255) NOT NULL COMMENT 'Unquoted 1', " .
"CHANGE unquoted2 unquoted2 VARCHAR(255) NOT NULL COMMENT 'Unquoted 2', " .
"CHANGE unquoted3 unquoted3 VARCHAR(255) NOT NULL COMMENT 'Unquoted 3', " .
"CHANGE `create` `create` VARCHAR(255) NOT NULL COMMENT 'Reserved keyword 1', " .
"CHANGE `table` `table` VARCHAR(255) NOT NULL COMMENT 'Reserved keyword 2', " .
"CHANGE `select` `select` VARCHAR(255) NOT NULL COMMENT 'Reserved keyword 3'"
);
}
}
......@@ -717,6 +717,48 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
*/
abstract protected function getQuotedAlterTableRenameColumnSQL();
/**
* @group DBAL-835
*/
public function testQuotesAlterTableChangeColumnLength()
{
$fromTable = new Table('mytable');
$fromTable->addColumn('unquoted1', 'string', array('comment' => 'Unquoted 1', 'length' => 10));
$fromTable->addColumn('unquoted2', 'string', array('comment' => 'Unquoted 2', 'length' => 10));
$fromTable->addColumn('unquoted3', 'string', array('comment' => 'Unquoted 3', 'length' => 10));
$fromTable->addColumn('create', 'string', array('comment' => 'Reserved keyword 1', 'length' => 10));
$fromTable->addColumn('table', 'string', array('comment' => 'Reserved keyword 2', 'length' => 10));
$fromTable->addColumn('select', 'string', array('comment' => 'Reserved keyword 3', 'length' => 10));
$toTable = new Table('mytable');
$toTable->addColumn('unquoted1', 'string', array('comment' => 'Unquoted 1', 'length' => 255));
$toTable->addColumn('unquoted2', 'string', array('comment' => 'Unquoted 2', 'length' => 255));
$toTable->addColumn('unquoted3', 'string', array('comment' => 'Unquoted 3', 'length' => 255));
$toTable->addColumn('create', 'string', array('comment' => 'Reserved keyword 1', 'length' => 255));
$toTable->addColumn('table', 'string', array('comment' => 'Reserved keyword 2', 'length' => 255));
$toTable->addColumn('select', 'string', array('comment' => 'Reserved keyword 3', 'length' => 255));
$comparator = new Comparator();
$this->assertEquals(
$this->getQuotedAlterTableChangeColumnLengthSQL(),
$this->_platform->getAlterTableSQL($comparator->diffTable($fromTable, $toTable))
);
}
/**
* Returns SQL statements for {@link testQuotesAlterTableChangeColumnLength}.
*
* @return array
*
* @group DBAL-835
*/
abstract protected function getQuotedAlterTableChangeColumnLengthSQL();
/**
* @group DBAL-807
*/
......
......@@ -634,6 +634,21 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
);
}
/**
* {@inheritdoc}
*/
protected function getQuotedAlterTableChangeColumnLengthSQL()
{
return array(
'ALTER TABLE mytable ALTER unquoted1 TYPE VARCHAR(255)',
'ALTER TABLE mytable ALTER unquoted2 TYPE VARCHAR(255)',
'ALTER TABLE mytable ALTER unquoted3 TYPE VARCHAR(255)',
'ALTER TABLE mytable ALTER "create" TYPE VARCHAR(255)',
'ALTER TABLE mytable ALTER "table" TYPE VARCHAR(255)',
'ALTER TABLE mytable ALTER "select" TYPE VARCHAR(255)',
);
}
/**
* @group DBAL-807
*/
......
......@@ -882,6 +882,14 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
);
}
/**
* {@inheritdoc}
*/
protected function getQuotedAlterTableChangeColumnLengthSQL()
{
$this->markTestIncomplete('Not implemented yet');
}
/**
* @group DBAL-807
*/
......
......@@ -435,6 +435,14 @@ class DB2PlatformTest extends AbstractPlatformTestCase
);
}
/**
* {@inheritdoc}
*/
protected function getQuotedAlterTableChangeColumnLengthSQL()
{
$this->markTestIncomplete('Not implemented yet');
}
/**
* @group DBAL-807
*/
......
......@@ -456,6 +456,14 @@ class OraclePlatformTest extends AbstractPlatformTestCase
);
}
/**
* {@inheritdoc}
*/
protected function getQuotedAlterTableChangeColumnLengthSQL()
{
$this->markTestIncomplete('Not implemented yet');
}
/**
* @group DBAL-807
*/
......
......@@ -846,6 +846,14 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
);
}
/**
* {@inheritdoc}
*/
protected function getQuotedAlterTableChangeColumnLengthSQL()
{
$this->markTestIncomplete('Not implemented yet');
}
/**
* @group DBAL-807
*/
......
......@@ -497,6 +497,20 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
);
}
/**
* {@inheritdoc}
*/
protected function getQuotedAlterTableChangeColumnLengthSQL()
{
return array(
'CREATE TEMPORARY TABLE __temp__mytable AS SELECT unquoted1, unquoted2, unquoted3, "create", "table", "select" FROM mytable',
'DROP TABLE mytable',
'CREATE TABLE mytable (unquoted1 VARCHAR(255) NOT NULL, unquoted2 VARCHAR(255) NOT NULL, unquoted3 VARCHAR(255) NOT NULL, "create" VARCHAR(255) NOT NULL, "table" VARCHAR(255) NOT NULL, "select" VARCHAR(255) NOT NULL)',
'INSERT INTO mytable (unquoted1, unquoted2, unquoted3, "create", "table", "select") SELECT unquoted1, unquoted2, unquoted3, "create", "table", "select" FROM __temp__mytable',
'DROP TABLE __temp__mytable',
);
}
/**
* @group DBAL-807
*/
......
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