yii2 icon indicating copy to clipboard operation
yii2 copied to clipboard

Update ActiveRelationTrait.php

Open spo0okie opened this issue 2 years ago • 1 comments

fix #19507

Q A
Is bugfix? ✔️
New feature?
Breaks BC?
Fixed issues #19507

spo0okie avatar Sep 19 '22 03:09 spo0okie

Thank you for putting effort in the improvement of the Yii framework. We have reviewed your pull request.

In order for the framework and your solution to remain stable in the future, we have a unit test requirement in place. Therefore we can only accept your pull request if it is covered by unit tests.

Could you add these please?

Thanks!

P.S. If you have any questions about the creation of unit tests? Don't hesitate to ask for support. More information about unit tests

This is an automated comment, triggered by adding the label pr:request for unit tests.

yii-bot avatar Sep 19 '22 07:09 yii-bot

Just waiting for some other team member to approve it and we are good to go.

bizley avatar Oct 04 '22 06:10 bizley

В db/ActiveRelationTrait.php, по-моему, есть баг.

Делаю запрос:

->joinWith([
    'dayRealTime',
    'user.usersWorkRoles.workRole.predictionType',
])

Получаю ошибку:

Undefined index: date

в функции filterByModels($models). date - это поле для связи по свойству dayRealTime.

847dd835b0

Если добавить проверку на наличие элемента в массиве, то ошибка уходит:

foreach ($prefixedLink as $attribute => $link) {
    $value = isset($model[$attribute]) || (is_object($model) && property_exists($model, $attribute)) ? $model[$attribute] : null;
    if ($value !== null) {
        $v[$attribute] = $model[$link];
    }
}

sigaryov avatar Oct 31 '22 09:10 sigaryov

@sigaryov it's better to create a separate issue for it. @arogachev would you please take a look?

samdark avatar Nov 07 '22 06:11 samdark

@samdark. OK. I'll check it.

@sigaryov Thanks for reporting. Could you share the relevant data structure (you can remove sensitive data)?

arogachev avatar Nov 07 '22 07:11 arogachev