Fix #17667: Fix CREATE INDEX failure on sqlite when specifying schema

This commit is contained in:
Alexander Makarov
2020-03-24 15:40:02 +03:00
committed by GitHub
parent 4de66f8205
commit 438cc80fc7
3 changed files with 32 additions and 0 deletions

View File

@@ -545,4 +545,22 @@ class QueryBuilder extends \yii\db\QueryBuilder
return trim($result);
}
/**
* {@inheritdoc}
*/
public function createIndex($name, $table, $columns, $unique = false)
{
$tableParts = explode('.', $table);
$schema = null;
if (count($tableParts) === 2) {
list ($schema, $table) = $tableParts;
}
return ($unique ? 'CREATE UNIQUE INDEX ' : 'CREATE INDEX ')
. $this->db->quoteTableName(($schema ? $schema . '.' : '') . $name) . ' ON '
. $this->db->quoteTableName($table)
. ' (' . $this->buildColumns($columns) . ')';
}
}