select "comments"., (select count() from "reactions" where "comments"."id" = "reactions"."comment_id" and "type" = like) as "likes_count", (select count() from "reactions" where "comments"."id" = "reactions"."comment_id" and "type" = dislike) as "dislikes_count", (select count() from "reactions" where "comments"."id" = "reactions"."comment_id" and "type" = happy) as "happies_count", (select count() from "reactions" where "comments"."id" = "reactions"."comment_id" and "type" = love) as "love_count", (select count() from "reactions" where "comments"."id" = "reactions"."comment_id" and "type" = sad) as "sads_count", (select count() from "comments" as "laravel_reserved_0" where "comments"."id" = "laravel_reserved_0"."reply_id") as "replies_count", (select count() from "reactions" where "comments"."id" = "reactions"."comment_id") as "reactions_count", (select count() from "reactions" inner join "comments" as "laravel_reserved_1" on "laravel_reserved_1"."id" = "reactions"."comment_id" where "comments"."id" = "laravel_reserved_1"."reply_id") as "reply_reactions_count", (select count() from "reactions" inner join "comments" as "laravel_reserved_2" on "laravel_reserved_2"."id" = "reactions"."comment_id" where "comments"."id" = "laravel_reserved_2"."reply_id" and "type" = dislike) as "reply_reactions_dislikes_count" from "comments" where "comments"."commentable_type" = App\Models\Utility\Documentation\Documentation and "comments"."commentable_id" = 1 and "comments"."commentable_id" is not null order by reactions_count - (dislikes_count 2) + (replies_count 2) + reply_reactions_count - (reply_reactions_dislikes_count * 2) desc limit 15 offset 0
Bug type
Behaviour
Commenter Version
2.0
Description
![Uploading image.png…]()
Here the query :
select "comments"., (select count() from "reactions" where "comments"."id" = "reactions"."comment_id" and "type" = like) as "likes_count", (select count() from "reactions" where "comments"."id" = "reactions"."comment_id" and "type" = dislike) as "dislikes_count", (select count() from "reactions" where "comments"."id" = "reactions"."comment_id" and "type" = happy) as "happies_count", (select count() from "reactions" where "comments"."id" = "reactions"."comment_id" and "type" = love) as "love_count", (select count() from "reactions" where "comments"."id" = "reactions"."comment_id" and "type" = sad) as "sads_count", (select count() from "comments" as "laravel_reserved_0" where "comments"."id" = "laravel_reserved_0"."reply_id") as "replies_count", (select count() from "reactions" where "comments"."id" = "reactions"."comment_id") as "reactions_count", (select count() from "reactions" inner join "comments" as "laravel_reserved_1" on "laravel_reserved_1"."id" = "reactions"."comment_id" where "comments"."id" = "laravel_reserved_1"."reply_id") as "reply_reactions_count", (select count() from "reactions" inner join "comments" as "laravel_reserved_2" on "laravel_reserved_2"."id" = "reactions"."comment_id" where "comments"."id" = "laravel_reserved_2"."reply_id" and "type" = dislike) as "reply_reactions_dislikes_count" from "comments" where "comments"."commentable_type" = App\Models\Utility\Documentation\Documentation and "comments"."commentable_id" = 1 and "comments"."commentable_id" is not null order by reactions_count - (dislikes_count 2) + (replies_count 2) + reply_reactions_count - (reply_reactions_dislikes_count * 2) desc limit 15 offset 0
Steps To Reproduce
Reproduce URL
Database
PgSql
No response