[SERVER-4674] aggregation: treat undefined values the same as null values Created: 12/Jan/12  Updated: 11/Jul/16  Resolved: 03/Jul/12

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 2.1.2
Fix Version/s: 2.2.0-rc0

Type: Bug Priority: Major - P3
Reporter: Chris Westin Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File unwind1.js    
Issue Links:
Depends
is depended on by SERVER-447 new aggregation framework Closed
Duplicate
is duplicated by SERVER-4638 issue with certain data types? Closed
Operating System: ALL
Participants:

 Description   

$group currently doesn't allow for the grouping key to be undefined. The attached script demonstrates the problem, yielding this error for the last two cases:

{
"errmsg" : "exception: the _id field for a group must not be undefined",
"code" : 15956,
"ok" : 0
}



 Comments   
Comment by auto [ 03/Jul/12 ]

Author:

{u'date': u'2012-06-29T12:41:38-07:00', u'email': u'mathias@10gen.com', u'name': u'Mathias Stearn'}

Message: Treat undefined as null in aggregation rather than erroring SERVER-4674
Branch: master
https://github.com/mongodb/mongo/commit/45b3dae6faea0dbf223acc8e53c34eb11b071fdc

Comment by auto [ 03/Jul/12 ]

Author:

{u'date': u'2012-06-29T12:22:44-07:00', u'email': u'mathias@10gen.com', u'name': u'Mathias Stearn'}

Message: Make test more clear SERVER-4674
Branch: master
https://github.com/mongodb/mongo/commit/ce91fa9de46717ae0d1bbbf85046558ff02f527f

Comment by auto [ 01/Mar/12 ]

Author:

{u'login': u'cwestin', u'name': u'U-tellus\\cwestin', u'email': u'cwestin@10gen.com'}

Message: SERVER-4674
Branch: master
https://github.com/mongodb/mongo/commit/d5bcc464a0479a2a07ab5299dc2b34c760857ea5

Comment by Chris Westin [ 12/Jan/12 ]

At the moment, you can work around this by preceding the $group with a $project in which you use a $ifNull to supply a value; $ifNull does treat undefined and null as the same. However, it makes me a bit nervous to do the same for group – I had a demonstrative test case come to me, but I've forgotten it; hopefully it will come back to me before I get to this, and we can decide if we care about it or not.

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