[SERVER-13903] inconsistent treatment of null in $project comparisons vs other stages Created: 12/May/14  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 2.6.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Asya Kamsky Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 2
Labels: eng-m, query-44-grooming, usability
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
is duplicated by SERVER-26180 is this a bug in $cond in $project, o... Closed
is duplicated by SERVER-20166 Aggregation's $eq expression doesn't ... Closed
Related
related to SERVER-18759 Add $isNull aggregation expression Backlog
Assigned Teams:
Query Optimization
Operating System: ALL
Participants:
Case:

 Description   

If a field is missing (undefined), in project stage it is impossible to determine that by comparing it to null.

 {$eq: ["$field", null] } 

only returns true if 'field' is present and null.

This is inconsistent with many other places, including ifNull treating null and undefined the same, as well as group (_id null and undefined all go into one bucket).

If this is intentional then it should be documented.

Tiny bit related to this is SERVER-6199



 Comments   
Comment by Asya Kamsky [ 03/Aug/20 ]

$isNull expression would allow such a check.

Comment by Asya Kamsky [ 15/Jul/15 ]

This turns out to be problematic as there is no test for $nullish values.

The only workaround to avoid errors is to use $ifNull to inject an explicit null so that comparison to null works.

Generated at Thu Feb 08 03:33:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.