diff --git a/CHANGELOG b/CHANGELOG index 8cb4036fb9..7cda74ec0c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -42,6 +42,7 @@ Version 1.1.8 work in progress - Enh #2341: More verbose log message for CModel::onUnsafeAttribute. Added model class (Sam Dark) - Enh #2357: Documented CWebApplication accessors with @property for better IDE autocomplete (Sam Dark) - Enh #2361: Added CDbConnection::pdoClass that allows to specify and use custom PDO wrapper class (Sam Dark) +- Enh #2365: Added support for creating more complex index by using createIndex() of query builder. (Qiang) - Enh #2389: MessageCommand now accepts overwrite option determining if merge result will overwrite existing file (Sam Dark) - Enh #2424: CDbConnection::beginTransaction() will now trigger a trace message for better debugging (Y!!) - Enh #2450: Added Ctype extension check to Yii requirements checker (Sam Dark) diff --git a/framework/db/schema/CDbSchema.php b/framework/db/schema/CDbSchema.php index 753f53cba2..2c9174c201 100644 --- a/framework/db/schema/CDbSchema.php +++ b/framework/db/schema/CDbSchema.php @@ -524,7 +524,7 @@ public function dropForeignKey($name, $table) * @param string $name the name of the index. The name will be properly quoted by the method. * @param string $table the table that the new index will be created for. The table name will be properly quoted by the method. * @param string $column the column(s) that should be included in the index. If there are multiple columns, please separate them - * by commas. The column names will be properly quoted by the method. + * by commas. Each column name will be properly quoted by the method, unless a parenthesis is found in the name. * @param boolean $unique whether to add UNIQUE constraint on the created index. * @return string the SQL statement for creating a new index. * @since 1.1.6 @@ -534,7 +534,12 @@ public function createIndex($name, $table, $column, $unique=false) $cols=array(); $columns=preg_split('/\s*,\s*/',$column,-1,PREG_SPLIT_NO_EMPTY); foreach($columns as $col) - $cols[]=$this->quoteColumnName($col); + { + if(strpos($col,'(')!==false) + $cols[]=$col; + else + $cols[]=$this->quoteColumnName($col); + } return ($unique ? 'CREATE UNIQUE INDEX ' : 'CREATE INDEX ') . $this->quoteTableName($name).' ON ' . $this->quoteTableName($table).' ('.implode(', ',$cols).')';