Fixes #15878: Fixed migration with a comment containing an apostrophe

This commit is contained in:
Marco Moreno
2018-03-14 17:51:32 -04:00
committed by Carsten Brandt
parent 61186b5bd5
commit f33959419a
3 changed files with 9 additions and 3 deletions

View File

@ -291,8 +291,9 @@ class QueryBuilder extends \yii\db\QueryBuilder
*/
public function addCommentOnColumn($table, $column, $comment)
{
$definition = $this->getColumnDefinition($table, $column);
$definition = trim(preg_replace("/COMMENT '(.*?)'/i", '', $definition));
// Strip existing comment which may include escaped quotes
$definition = trim(preg_replace("/COMMENT '(?:''|[^'])*'/i", '',
$this->getColumnDefinition($table, $column)));
return 'ALTER TABLE ' . $this->db->quoteTableName($table)
. ' CHANGE ' . $this->db->quoteColumnName($column)