Skip to content

findBy no longer supports array values for fields after v2.7.1 #992

@francisber

Description

@francisber

After upgrading from foundry v2.7.0 → v2.7.1, we noticed a breaking change in how findBy handles array criteria.

Previously, passing an array of values for a field was translated into an IN() query (expected behavior). Example (worked before):

$entities = SomeEntityFactory::findBy([
    'status' => ['draft', 'published', 'archived'],
]);

This correctly generated:

SELECT e FROM App\Entity\SomeEntity e WHERE e.status IN (:status)

After v2.7.1, the same code now collapses the array into a single = comparison instead of IN(). The resulting DQL is:

SELECT e FROM App\Entity\SomeEntity e WHERE e.status = :status

This breaks a common use case where multiple values must be matched in one query. It also slows down test execution, since multiple queries are now required to achieve the same result.

Steps to Reproduce:

  • Create several entities with different values for the same field.
  • Call Factory::findBy(['fieldName' => ['value1', 'value2']]).
  • Observe that only a single value is used in the query instead of an IN() clause.

Expected Behavior:

  • findBy should continue supporting field-value arrays and generate an IN() query.

Impact:

  • Breaks existing test setups relying on findBy with arrays.
  • Increases query count (slower tests).
  • Forces manual workarounds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions