-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
Hi,
there is an issue with the new alias()
function in Yii 2.0.7.
If you use an alias for the primary table the function anyTagValues
in the class TaggableQueryBehavior
returns an error.
I think you should change the function in this way:
public function anyTagValues($values, $attribute = null)
{
$model = new $this->owner->modelClass();
$query = $this->owner;
$tagClass = $model->getRelation($model->tagRelation)->modelClass;
$this->owner
->innerJoinWith($model->tagRelation, false)
->andWhere([$tagClass::tableName() . '.' . ($attribute ?: $model->tagValueAttribute) => $model->filterTagValues($values)])
->addGroupBy(array_map(function ($pk) use ($model,$query) {
return array_search($model->tableName(),$query->from) . '.' . $pk;
}, $model->primaryKey()));
return $this->owner;
}
You don't have to get the table name from $model->tableName()
but from the $from
variable in the ActiveQuery
object.
regards
Metadata
Metadata
Assignees
Labels
No labels