Details
-
Bug
-
Resolution: Done
-
Minor - P4
-
None
-
3.0.5
-
None
-
ALL
Description
The following behavior seems like a bug to me:
> db.test.insert({ "_id" : ObjectId("55d386eeb4a9494cd24e94fc"), "name" : "test", "myarray" : [ ] });
|
WriteResult({ "nInserted" : 1 })
|
> db.test.aggregate([{'$group' : {'_id' : '$name', 'thing' : {'$first' : '$myarray.made_up_field'}}}]);
|
{ "_id" : "test", "thing" : [ ] }
|
Why does "thing" get set to an empty array? It should be null?
I ran into this problem while doing a $push like the following during a $group phase
'inventory' => ['$push' => [
|
warehouse' => '$sku.inventory.warehouse',
|
at_once' => '$sku.inventory.at_once'
|
]]
|
and getting an empty array for warehouse often times instead of a string when sku.inventory was an empty array.