orm: DDC-3063: Unexpected behavior with 'WHERE NOT IN' and empty array

Jira issue originally created by user timstamp:

I tried to set version to 2.4.0 but was prevented.

Assume the set ‘n’ contains 10 records, all with id > 0.

->andWhere('n.id NOT IN (:ids)')->setParameter('ids', [])
returns 0 records.

->andWhere('n.id NOT IN (:ids)')->setParameter('ids', [0])
returns 10 records.

About this issue

  • Original URL
  • State: open
  • Created 10 years ago
  • Comments: 19 (1 by maintainers)

Most upvoted comments

Still a problem that i’m continuously bumping into. Ugly solutions do fix it but are only temporary.

Comment created by @ocramius:

[~timstamp] yeah, when using IN() and NOT IN() you should actually check if the parameters are empty or not before adding the clause.