Skip to content

Commit bdc345b

Browse files
committed
Reduce duplication of collation declaration code
It is safe to quote collation in the default implementation of getColumnCollationDeclarationSQL() since those platforms where the case sensitivity of an identifier depends on whether it's quoted (Oracle, IBM DB2) do not support column collation anyways.
1 parent e5e8607 commit bdc345b

File tree

4 files changed

+2
-30
lines changed

4 files changed

+2
-30
lines changed

src/Platforms/AbstractMySQLPlatform.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,16 +1028,6 @@ public function getColumnCharsetDeclarationSQL($charset)
10281028
return 'CHARACTER SET ' . $charset;
10291029
}
10301030

1031-
/**
1032-
* {@inheritDoc}
1033-
*
1034-
* @internal The method should be only used from within the {@see AbstractPlatform} class hierarchy.
1035-
*/
1036-
public function getColumnCollationDeclarationSQL($collation)
1037-
{
1038-
return 'COLLATE ' . $this->quoteSingleIdentifier($collation);
1039-
}
1040-
10411031
/**
10421032
* {@inheritDoc}
10431033
*

src/Platforms/AbstractPlatform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3321,7 +3321,7 @@ public function getColumnCharsetDeclarationSQL($charset)
33213321
*/
33223322
public function getColumnCollationDeclarationSQL($collation)
33233323
{
3324-
return $this->supportsColumnCollation() ? 'COLLATE ' . $collation : '';
3324+
return $this->supportsColumnCollation() ? 'COLLATE ' . $this->quoteSingleIdentifier($collation) : '';
33253325
}
33263326

33273327
/**

src/Platforms/PostgreSQLPlatform.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,16 +1302,6 @@ public function supportsColumnCollation()
13021302
return true;
13031303
}
13041304

1305-
/**
1306-
* {@inheritdoc}
1307-
*
1308-
* @internal The method should be only used from within the {@see AbstractPlatform} class hierarchy.
1309-
*/
1310-
public function getColumnCollationDeclarationSQL($collation)
1311-
{
1312-
return 'COLLATE ' . $this->quoteSingleIdentifier($collation);
1313-
}
1314-
13151305
/**
13161306
* {@inheritdoc}
13171307
*/

tests/Platforms/SqlitePlatformTest.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -787,14 +787,6 @@ public function testSupportsColumnCollation(): void
787787
self::assertTrue($this->platform->supportsColumnCollation());
788788
}
789789

790-
public function testColumnCollationDeclarationSQL(): void
791-
{
792-
self::assertSame(
793-
'COLLATE NOCASE',
794-
$this->platform->getColumnCollationDeclarationSQL('NOCASE'),
795-
);
796-
}
797-
798790
public function testGetCreateTableSQLWithColumnCollation(): void
799791
{
800792
$table = new Table('foo');
@@ -804,7 +796,7 @@ public function testGetCreateTableSQLWithColumnCollation(): void
804796
self::assertSame(
805797
[
806798
'CREATE TABLE foo (no_collation VARCHAR(255) NOT NULL, '
807-
. 'column_collation VARCHAR(255) NOT NULL COLLATE NOCASE)',
799+
. 'column_collation VARCHAR(255) NOT NULL COLLATE "NOCASE")',
808800
],
809801
$this->platform->getCreateTableSQL($table),
810802
);

0 commit comments

Comments
 (0)