-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Server
-
Labels:None
In SERVER-1475, fixed in 3.5.7 and planned to be made generally available in the 3.6.0 release, we made a minor breaking change to the behavior of the $type query operator. The operator's existing reference page is here:
https://docs.mongodb.com/manual/reference/operator/query/type/
Specifically, we changed the behavior of $type:"array". Previously, such a query would only match documents with nested arrays:
> db.c.find() { "_id" : ObjectId("59108bb673650abe22f32a56"), "a" : [ 1, 2, 3 ] } { "_id" : ObjectId("59108bbc73650abe22f32a57"), "a" : [ 1, [ 2, 3 ] ] } > db.c.find({a: {$type: "array"}}) { "_id" : ObjectId("59108bbc73650abe22f32a57"), "a" : [ 1, [ 2, 3 ] ] }
The new behavior, which we believe to be more intuitive and more consistent with existing query semantics, is to match both nested arrays and non-nested arrays:
> db.c.find({a: {$type: "array"}}) { "_id" : ObjectId("59108bb673650abe22f32a56"), "a" : [ 1, 2, 3 ] } { "_id" : ObjectId("59108bbc73650abe22f32a57"), "a" : [ 1, [ 2, 3 ] ] }
This change needs to be documented as part of the Compatibility Changes page in the 3.6 release notes. We also need to update the Querying by Array Type section for the 3.6 references pages, since this currently is dedicated to describing the old behavior.
- documents
-
SERVER-1475 {field: {$type:"array"}} should return documents where "field" is an array
- Closed