mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 05:48:11 +08:00
Fixes #13814: MySQL unique index names can now contain spaces
This commit is contained in:
committed by
Alexander Makarov
parent
940377ce56
commit
a2a79a70eb
@ -447,11 +447,11 @@ SQL;
|
||||
$sql = $this->getCreateTableSql($table);
|
||||
$uniqueIndexes = [];
|
||||
|
||||
$regexp = '/UNIQUE KEY\s+([^\(\s]+)\s*\(([^\(\)]+)\)/mi';
|
||||
$regexp = '/UNIQUE KEY\s+\`(.+)\`\s*\((\`.+\`)+\)/mi';
|
||||
if (preg_match_all($regexp, $sql, $matches, PREG_SET_ORDER)) {
|
||||
foreach ($matches as $match) {
|
||||
$indexName = str_replace('`', '', $match[1]);
|
||||
$indexColumns = array_map('trim', explode(',', str_replace('`', '', $match[2])));
|
||||
$indexName = $match[1];
|
||||
$indexColumns = array_map('trim', explode('`,`', trim($match[2], '`')));
|
||||
$uniqueIndexes[$indexName] = $indexColumns;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user