Skip to content

When relation is morphMany, withCount would cause where bindings mistake #26635

Closed
@mitoop

Description

@mitoop
  • Laravel Version: 5.7.13
  • PHP Version: 7.2.11
  • Database Driver & Version: Mysql 8.0.12

Description:

When use withCount under the relation morphMany and when withCount method call before select method, It will lead that the where bindings will make a mistake.

Steps To Reproduce:

ModelA::withCount('relation')->where(''user_id", 12)->select(['fields'])->get() or paginate().

It will cause where bindings make a mistake. And when select method call before the withCount method, It will be OK. Like this :

ModelA::select(['fields'])->withCount('relation')->where(''user_id", 12)->get() or paginate().

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions