Skip to content

Commit dbbf0fd

Browse files
authored
Add collation support for uuid columns in MySQL (#19290)
The uuid type generates CHAR(36) SQL but was not included in the $hasCollate array, causing column collation to be silently ignored. This fix adds TYPE_UUID to the $hasCollate array in MysqlSchemaDialect so that collation is properly applied to uuid columns. Refs cakephp/migrations#1020 * Add collation support for uuid columns in MySQL The uuid type generates CHAR(36) SQL but was not included in the $hasCollate array, causing column collation to be silently ignored. This fix: 1. Adds TYPE_UUID to the $hasCollate array in MysqlSchemaDialect 2. Adds 'uuid' to $_columnExtras in TableSchema to allow 'collate' attribute to be preserved when adding columns Refs cakephp/migrations#1020
1 parent f0b893e commit dbbf0fd

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

Schema/MysqlSchemaDialect.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,7 @@ public function columnDefinitionSql(array $column): string
834834
TableSchemaInterface::TYPE_TEXT,
835835
TableSchemaInterface::TYPE_CHAR,
836836
TableSchemaInterface::TYPE_STRING,
837+
TableSchemaInterface::TYPE_UUID,
837838
];
838839
if (in_array($column['type'], $hasCollate, true) && isset($column['collate']) && $column['collate'] !== '') {
839840
$out .= ' COLLATE ' . $column['collate'];

Schema/TableSchema.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ class TableSchema implements TableSchemaInterface, SqlGeneratorInterface
144144
'text' => [
145145
'collate' => null,
146146
],
147+
'uuid' => [
148+
'collate' => null,
149+
],
147150
'tinyinteger' => [
148151
'unsigned' => null,
149152
'autoIncrement' => null,

0 commit comments

Comments
 (0)