Browse Source

fix issue with composite key in combination with join

fixes #10201
fixes #9047
close #9895
tags/2.0.8
Carsten Brandt 9 years ago
parent
commit
52e23e0317
  1. 1
      framework/CHANGELOG.md
  2. 8
      framework/db/ActiveRelationTrait.php

1
framework/CHANGELOG.md

@ -12,6 +12,7 @@ Yii Framework 2 Change Log
- Bug #11196: Fixed VarDumper throws PHP Fatal when dumping `__PHP_Incomplete_Class` (DamianZ)
- Bug #7627: Fixed `yii\widgets\ActiveField` to handle inputs AJAX validation with changed ID properly (dizeee)
- Bug #9851: Fixed partial commit / rollback in nested transactions (sammousa)
- Bug #10201: Fixed bug in ActiveRecord, where relational data could not be fetched in case with composite key and join with IN condition (PaulVanSchayck, airmoi, joe-meyer, cebe)
- Bug #10480: Fixed removing old identity cookie when loggin in as another user without logging out first (maine-mike)
- Bug #10617: Fixed `yii\web\Request::getBodyParams()` returned `null` instead of empty array if request body is empty and content type is application/json (samdark)
- Bug #10784: Fixed `yii\grid\CheckboxColumn` to set correct value when `yii\grid\CheckboxColumn::$checkboxOptions` closure is used (nukkumatti)

8
framework/db/ActiveRelationTrait.php

@ -469,9 +469,15 @@ trait ActiveRelationTrait
}
} else {
// composite keys
// ensure keys of $this->link are prefixed the same way as $attributes
$prefixedLink = array_combine(
$attributes,
array_values($this->link)
);
foreach ($models as $model) {
$v = [];
foreach ($this->link as $attribute => $link) {
foreach ($prefixedLink as $attribute => $link) {
$v[$attribute] = $model[$link];
}
$values[] = $v;

Loading…
Cancel
Save