spotorm / spot2

Spot v2.x DataMapper built on top of Doctrine's Database Abstraction Layer
http://phpdatamapper.com
BSD 3-Clause "New" or "Revised" License
601 stars 101 forks source link

Query operators fail to handle arrays with null values #262

Open marcojetson opened 6 years ago

marcojetson commented 6 years ago

$where = ['user_id' => [1, 2, null]]

gets converted into

WHERE user_id IN (1, 2, null)

instead of

user_id IN (1, 2) OR user_id IS NULL

FlipEverything commented 6 years ago

We have to look into this. In the meantime could you please test if the following code is working for you?

// untested
$spot->mapper($entityName)->where(['user_id' => [1, 2]])->orWhere(['user_id' => null]]);

In the future we have to cover this case with tests.