Closed
Description
Laravel Version
12.10.1
PHP Version
8.4.6
Database Driver & Version
MySQL 8.0.33 for macOS 15.4.1 (DBngin)
Description
When using the whereAttachedTo
method, the entire model and all its properties are sent into whereKey
which then converts all columns to an integer and adds them to the whereIn clause. This means a bunch of 0's are added for empty strings / null values, which is unlikely to cause an issue but is still unintended behaviour. But integer and datetime columns add a bunch of potentially valid IDs which should not be included in the query.

Steps To Reproduce
Create a belongsToMany
or MorphToMany
relationship between two models.
Write an Eloquent query including the whereAttachedTo
method and pass the other model in. Either call ddRawSql
on this query or call get
and inspect the DB query log.
Metadata
Metadata
Assignees
Labels
No labels