Details
-
Question
-
Resolution: Duplicate
-
Major - P3
-
None
-
4.2.9
-
None
-
Execution Team 2020-11-16, Execution Team 2020-12-14, Execution Team 2020-12-28, Execution Team 2021-01-11, Execution Team 2021-01-25
Description
According to https://docs.mongodb.com/manual/reference/bson-type-comparison-order/#objects, embedded objects/documents are compared, first, by field names, second, by field values.
Consider a collection:
{_id: 1, tag: {bab: 123}} |
{_id: 2, tag: {bar: "BAR"}} |
{_id: 3, tag: {baz: "BAZ"}} |
and a query:
{tag: {$gte: {baz: MinKey()}}}
|
I thought this would return ONLY doc 3 (since `bab` and `bar` are less than `baz`), but it returns ALL three docs. Changing the query to
{tag: {$gte: {baz: ""}}} |
returns ONLY doc 3, as I hoped.
Is this an issue? Are range queries supported on whole embedded objects values? Do MinKey and MaxKey have some weird behavior in queries embedded documents?
Attachments
Issue Links
- duplicates
-
DOCS-14025 Comparison/Sort Order documentation for objects is incorrect
-
- Closed
-
- is caused by
-
DOCS-14025 Comparison/Sort Order documentation for objects is incorrect
-
- Closed
-
- is duplicated by
-
SERVER-51383 bsonWoCompare on embedded documents/objects does not match ordering described in documentation
-
- Closed
-