cms icon indicating copy to clipboard operation
cms copied to clipboard

[4.x]: "Not in" queries returning incorrect results for columns that have `null` values.

Open nfourtythree opened this issue 2 years ago • 0 comments

What happened?

Description

When create queries that use syntax along the lines of ['not', 'a', 'b', 'c'] the Db helper method parseParam() refines this to the following SQL (based on the column name of myColumn)

WHERE (NOT (`table_name`.`myColumn` IN ('a', 'b', 'c')))

With the data below you would expect IDs 4, 5 and 6 returned but only 4 and 5 are.

ID myColumn
1 'a'
2 'b'
3 'c'
4 'd'
5 ''
6 null

Expected behavior

null values are returned when using "Not in"

Craft CMS version

4.x

PHP version

8.0

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

No response

nfourtythree avatar Sep 13 '22 17:09 nfourtythree