Details
Description
Instead of failing, $type parsing converts a non-integral type code to -1, which is the type code for MinKey:
> db.c.drop()
|
true
|
> db.c.insert({a: 1})
|
WriteResult({ "nInserted" : 1 })
|
> db.c.insert({a: MinKey()})
|
WriteResult({ "nInserted" : 1 })
|
> db.c.insert({a: "foo"})
|
WriteResult({ "nInserted" : 1 })
|
> db.c.insert({a: MaxKey()})
|
WriteResult({ "nInserted" : 1 })
|
> db.c.find({a: {$type: -1}})
|
{ "_id" : ObjectId("596925106d078d9cebb74764"), "a" : { "$minKey" : 1 } }
|
> db.c.find({a: {$type: 1.5}})
|
{ "_id" : ObjectId("596925106d078d9cebb74764"), "a" : { "$minKey" : 1 } }
|
> db.c.find({a: {$type: 2.1}})
|
{ "_id" : ObjectId("596925106d078d9cebb74764"), "a" : { "$minKey" : 1 } }
|
This behavior is due to the parser implementation here:
Attachments
Issue Links
- causes
-
SERVER-31623 MatcherTypeSet::parseSingleType() should not cast large doubles to integer
-
- Closed
-