[Debugging] introduced test case that shows join reaction counter breaks when run with count on morphables #260
      
        
          +201
        
        
          −4
        
        
          
        
      
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Hi @antonkomarev, this PR is to demonstrate some breaks that are happening when the
joinReactionCounterOfTypeis called with thewithCountmethod 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)