-
Type:
Bug
-
Resolution: Works as Designed
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Execution
-
ALL
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
0
To reproduce:
MongoDB Enterprise > db.c.insert({_id: 0, bson: 100});
WriteResult({ "nInserted" : 1 })
MongoDB Enterprise > db.c.aggregate([{
$project: {
_id: 0,
output: {
$convert:
{to: {type: "binData", subtype: 2}, input: "$bson", format: "base64"}
}
}
}]);
{ "output" : BinData(2,"AAAAAAAAWUA=") }
MongoDB Enterprise >
A BinData subtype of 2 represents a String. But that's incorrect for this bindata.
We should be checking the `subtype` field in all conversions to BinData such that they match the intended type.
For example, this function for numbers just blindly passes the subtype to the returned BinData: https://github.com/10gen/mongo/blob/master/src/mongo/db/exec/expression/evaluate_math.cpp#L1481
We should audit all conversions functions to bindata and verify that they check BinData subtypes correctly.
- related to
-
SERVER-108654 Complete TODO listed in SERVER-105121
-
- Closed
-
-
SERVER-111847 Complete TODO listed in SERVER-105121
-
- Closed
-