You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scope joinReactionCounterOfType not working when used with select
Logs:
Comment::select('comments.name')->joinReactionCounterOfType('Like')->orderBy('reaction_like_count', 'desc')->get();
Illuminate\Database\QueryException SQLSTATE[42S22]: Column not found: 1054 Unknown column 'reaction_like_count' in 'order clause' (Connection: mysql, SQL: select `comments.name` from `comments` left join `love_reactant_reaction_counters` as `reaction_like` on `reaction_like`.`reactant_id` = `comments`.`love_reactant_id` and `reaction_like`.`reaction_type_id` = 2 order by `reaction_like_count` desc).
The text was updated successfully, but these errors were encountered:
@antonkomarev Ah I see the problem, if I use addGlobalScope to select, the query doesn't include COALESCE(reaction_like.count, 0) as reaction_like_count, COALESCE(reaction_like.weight, 0) as reaction_like_weight, so even if I select reaction_like_count column too, it still fails.
static::addGlobalScope('scope1', function (Builder $builder) {
$builder->select('comments.name');
});
Scope joinReactionCounterOfType not working when used with select
Logs:
The text was updated successfully, but these errors were encountered: