If a field is marked as null then it DOES exist and doesn't return. By searching for a null we cover both cases: the case where the field doesn't exist AND the case where the field really IS null.
I already fixed it for isNull, isNotNull ODM filters, I'm just raising this as an issue here in case I missed something? I can put in a pull request if there are no objections.
IsNull.php:22
$queryBuilder->$queryType($queryBuilder->expr()->field($option['field'])->exists(false));
If I have a field in my document, "foo" that is set to null, I would expect that filtering as follows:
Would return my document, but it doesn't. This is the query that runs:
db.getCollection('myCollection').find({foo:{$exists:false}})
I suggest that a much better match would be:
db.getCollection('myCollection').find({foo:null})
If a field is marked as null then it DOES exist and doesn't return. By searching for a null we cover both cases: the case where the field doesn't exist AND the case where the field really IS null.
I already fixed it for isNull, isNotNull ODM filters, I'm just raising this as an issue here in case I missed something? I can put in a pull request if there are no objections.