From 9c4c98420071d4e7bbacade8353651403e2180ca Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Thu, 2 Jul 2015 15:20:32 +0200 Subject: [PATCH] improved docs and changelog for #8903 --- framework/CHANGELOG.md | 1 + framework/db/pgsql/QueryBuilder.php | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 80e04bda19..6b878552b9 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -36,6 +36,7 @@ Yii Framework 2 Change Log - Enh #8574: Added `yii\console\controllers\MessageController` support .pot file creation (pgaultier) - Enh #8625: Added `markUnused` option to `yii\console\controllers\MessageController` (marius7383) - Enh #8670: Added support for saving extra fields in session table for `yii\web\DbSession` (klimov-paul) +- Enh #8903: PostgreSQL `QueryBuilder::createIndex()` can now specify the index method to use (LAV45) - Chg #6354: `ErrorHandler::logException()` will now log the whole exception object instead of only its string representation (cebe) - Chg #8556: Extracted `yii\web\User::getAuthManager()` method (samdark) diff --git a/framework/db/pgsql/QueryBuilder.php b/framework/db/pgsql/QueryBuilder.php index d824b3601f..5aa3cad08c 100644 --- a/framework/db/pgsql/QueryBuilder.php +++ b/framework/db/pgsql/QueryBuilder.php @@ -18,13 +18,24 @@ use yii\base\InvalidParamException; class QueryBuilder extends \yii\db\QueryBuilder { /** - * You can use any of these indexes for the postgresql 8.2+ version - * @see http://www.postgresql.org/docs/8.2/static/sql-createindex.html + * Defines a UNIQUE index for [[createIndex()]]. */ const INDEX_UNIQUE = 'unique'; + /** + * Defines a B-tree index for [[createIndex()]]. + */ const INDEX_B_TREE = 'btree'; + /** + * Defines a hash index for [[createIndex()]]. + */ const INDEX_HASH = 'hash'; + /** + * Defines a GiST index for [[createIndex()]]. + */ const INDEX_GIST = 'gist'; + /** + * Defines a GIN index for [[createIndex()]]. + */ const INDEX_GIN = 'gin'; /** @@ -81,8 +92,11 @@ class QueryBuilder extends \yii\db\QueryBuilder * @param string|array $columns the column(s) that should be included in the index. If there are multiple columns, * separate them with commas or use an array to represent them. Each column name will be properly quoted * by the method, unless a parenthesis is found in the name. - * @param boolean|string $unique whether to add UNIQUE constraint or if is $unique string create some of index. + * @param boolean|string $unique whether to make this a UNIQUE index constraint. You can pass `true` or [[INDEX_UNIQUE]] to create + * a unique index, `false` to make a non-unique index using the default index type, or one of the following constants to specify + * the index method to use: [[INDEX_B_TREE]], [[INDEX_HASH]], [[INDEX_GIST]], [[INDEX_GIN]]. * @return string the SQL statement for creating a new index. + * @see http://www.postgresql.org/docs/8.2/static/sql-createindex.html */ public function createIndex($name, $table, $columns, $unique = false) {