Skip to content

Commit

Permalink
Select only primary keys in UniqueValidator (yiisoft#10896) (yiisoft#…
Browse files Browse the repository at this point in the history
  • Loading branch information
developeruz authored and cebe committed Dec 1, 2016
1 parent 081ee7c commit 729ddc5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Yii Framework 2 Change Log
- Enh #7333: Improved error message for `yii\di\Instance::ensure()` when a component does not exist (cebe)
- Enh #7420: Attributes for prompt generated with `renderSelectOptions` of `\yii\helpers\Html` helper (arogachev)
- Enh #9162: Added support of closures in `value` for attributes in `yii\widgets\DetailView` (arogachev)
- Enh #10896: Select only primary key when counting records in UniqueValidator (developeruz)
- Enh #11037: `yii.js` and `yii.validation.js` use `Regexp.test()` instead of `String.match()` (arogachev, nkovacs)
- Enh #11756: Added type mapping for `varbinary` data type in MySQL DBMS (silverfire)
- Enh #11929: Changed `type` column type from `int` to `smallInt` in RBAC migrations (silverfire)
Expand All @@ -54,7 +55,6 @@ Yii Framework 2 Change Log
- Enh #13050: Added `yii\filters\HostControl` allowing protection against 'host header' attacks (klimov-paul)
- Enh: Added constants for specifying `yii\validators\CompareValidator::$type` (cebe)


2.0.10 October 20, 2016
-----------------------

Expand Down
2 changes: 1 addition & 1 deletion framework/validators/UniqueValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function validateAttribute($model, $attribute)
} else {
// if current $model is in the database already we can't use exists()
/* @var $models ActiveRecordInterface[] */
$models = $query->limit(2)->all();
$models = $query->select($targetClass::primaryKey())->limit(2)->all();
$n = count($models);
if ($n === 1) {
$keys = array_keys($params);
Expand Down

0 comments on commit 729ddc5

Please sign in to comment.