Add tests for column collation to prove it works#2919
Add tests for column collation to prove it works#2919Ocramius merged 1 commit intodoctrine:masterfrom Tobion:test-column-collation
Conversation
|
@Ocramius this is ready |
Majkl578
left a comment
There was a problem hiding this comment.
Retriggered the continuousphp build, looks ok now.
| self::assertNotContains('DATABASE()', $sql); | ||
| } | ||
|
|
||
| public function testSupportsColumnCollation() |
There was a problem hiding this comment.
Can you please add : void for all new test methods?
There was a problem hiding this comment.
Sure but shouldn't that be changed everywhere in another PR? Just doing it here is inconsistent.
There was a problem hiding this comment.
True, CS is currently not enforced on project level, except checking for some basic rules for new PRs, But soon will be - if we do it like this now, it won't need further fixes in few weeks. 👍
| $table->addColumn('column_collation', 'string')->setPlatformOption('collation', 'ascii_general_ci'); | ||
|
|
||
| self::assertSame( | ||
| array('CREATE TABLE foo (no_collation VARCHAR(255) NOT NULL, column_collation VARCHAR(255) NOT NULL COLLATE ascii_general_ci) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'), |
There was a problem hiding this comment.
Short array syntax should be used.
|
@Majkl578 fixed CS. |
|
Rebased. Please merge |
|
👍 |
|
Had to restart some builds, but otherwise all is green now :) Thanks @Tobion! |
Fixes #2551
The main point is that one must use the platform or the custom option for the
collationand not the standard option for columns. The reasoning I guess is that those options are not cross-RDBMS compatible. There are two things that are inconsistent and causing alot of the confusion:\Doctrine\DBAL\Schema\Column::setPlatformOption, see https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php#L203\Doctrine\DBAL\Schema\Column::setCustomSchemaOption, see https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/SchemaTool.php#L460collationbut on the table level the option is calledcollate(only relevant for mysql, see https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php#L499 )