cybercog / laravel-love

Add Social Reactions to Laravel Eloquent Models. It lets people express how they feel about the content. Fully customizable Weighted Reaction System & Reaction Type System with Like, Dislike and any other custom emotion types. Do you react?
https://komarev.com/sources/laravel-love
MIT License
1.17k stars 71 forks source link

[Debugging] introduced test case that shows join reaction counter breaks when run with count on morphables #260

Open jfunulab opened 1 month ago

jfunulab commented 1 month ago

Hi @antonkomarev, this PR is to demonstrate some breaks that are happening when the joinReactionCounterOfType is called with the withCount method on morphable relations. The issue is not apparent when run in the in-memory database but when you switch to a mysql connection it shows up.

The error that shows up is Illuminate\Database\QueryException: SQLSTATE[HY093]: Invalid parameter number (Connection: mysql, SQL: selectarticles.*, (select count(*) frommorphable_entitieswherearticles.id=morphable_entities.morphable_idandmorphable_entities.morphable_type= 1) asmorphable_entities_count, COALESCE(reaction_like.count, 0) as reaction_like_count, COALESCE(reaction_like.weight, 0) as reaction_like_weight fromarticlesleft joinlove_reactant_reaction_countersasreaction_likeonreaction_like.reactant_id=articles.love_reactant_idandreaction_like.reaction_type_id= ? order byreaction_like_countasc)

antonkomarev commented 1 month ago

@jfunulab thank you for the report. I will try to find time for research.