Details
-
Bug
-
Resolution: Duplicate
-
Major - P3
-
None
-
4.2.9
-
None
-
ALL
Description
According to https://docs.mongodb.com/manual/reference/bson-type-comparison-order/#objects objects are compared field-by-field (in order that they're stored):
1. by field key name
2. by field value
I ran into some issues with some queries and after some research, I have some interesting results from bsonWoCompare:
> bsonWoCompare({foo: 0}, {bar: 1}) |
1
|
> bsonWoCompare({foo: 0}, {bar: "BAR"}) |
-5 |
> bsonWoCompare({foo: true}, {bar: "BAR"}) |
25
|
> bsonWoCompare({foo: ""}, {bar: "BAR"}) |
1
|
> bsonWoCompare({foo: MinKey()}, {bar: "BAR"}) |
-16 |
> bsonWoCompare({foo: MaxKey()}, {bar: "BAR"}) |
112 |
Since "foo" > "bar", shouldn't bsonWoCompare always return a positive result, regardless of field values?
Attachments
Issue Links
- duplicates
-
SERVER-51258 Unexpected behavior in range query on whole embedded documents with MinKey and MaxKey subfield values
-
- Closed
-