Yii2: wrong condition in ActiveQuery::viaTable()

Created on 12 Mar 2018  路  2Comments  路  Source: yiisoft/yii2

See https://github.com/yiisoft/yii2/commit/64d8af61a64db0b00d498800e1f20e62b4473329#diff-1776bc9373c1dbb0d6e77ba4d8081a81L762

The change is not correct, using ActiveQuery as $modelClass does not make sense. The call should fail if called on a non-relational query (i.e. if primaryModel is null).

bug

Most helpful comment

Despite it was a bug, it did not affect working code because the viaTable() call on empty primaryModel does not make sense and could be caused only by wrong manual configuration of the ActiveQuery object.

All 2 comments

Despite it was a bug, it did not affect working code because the viaTable() call on empty primaryModel does not make sense and could be caused only by wrong manual configuration of the ActiveQuery object.

Heh, actually it makes sense. Thanks to failed tests to point that out :)
It makes sense for viaTable() called from other query closure (like this) during lazy loading of relations.

Fixed with commits 025dd072c and b9ee17014
Seems to be OK now

Was this page helpful?
0 / 5 - 0 ratings