|
The BSON specification mandates that a field of type boolean is a byte with either the value \x00 or \x01. The server does not check this as part of the BSON validation process. If a poorly written driver incorrectly used a different value to represent true or false, undefined behavior will result. For example, if I insert hand-crafted BSON where the value of a field "b" is of type boolean and the byte value is \x02:
> db.test.find()
|
{ "_id" : ObjectId("55806db733ee03327f4907ea"), "b" : true }
|
> db.test.count({b : true})
|
0
|
> db.test.count({b : false})
|
0
|
Furthermore, BSON decoders in different languages are written differently. Some convert the byte to a boolean with a check like "b != \x00", while others do "b == \x01", so the former would decode this field as true, while the latter will decode it as false.
|