-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
-
ALL
-
QE 2022-07-25, QE 2022-08-08, QE 2022-08-22
While working on SERVER-67326 we noticed a weird behavior of `showRecordId()` and not sure it is working at expected.
`showRecordId()` is a shell method which "modifies the output of a query by adding a field $recordId to matching documents".
While running the following queries, I assumed that all of them should have `$recordId` in their output. However, this is only the case for the first one.
jsTestLog(coll.find({}).showRecordId().toArray()); jsTestLog(coll.find({}, {$recordId: 1}).toArray()); jsTestLog(coll.find({}, {$recordId: 1}).showRecordId().toArray());
Here is the output:
,---- | [ | { | "_id" : ObjectId("62b619e0d3af55ae13afb1cf"), | "a" : 1, | "b" : 1, | "$recordId" : NumberLong(1) | }, | { | "_id" : ObjectId("62b619e0d3af55ae13afb1d0"), | "a" : 1, | "b" : 2, | "$recordId" : NumberLong(2) | }, | { | "_id" : ObjectId("62b619e0d3af55ae13afb1d1"), | "a" : 2, | "b" : 2, | "$recordId" : NumberLong(3) | }, | { | "_id" : ObjectId("62b619e0d3af55ae13afb1d2"), | "a" : 2, | "b" : 3, | "$recordId" : NumberLong(4) | } | ] `---- ,---- | [ | { | "_id" : ObjectId("62b619e0d3af55ae13afb1cf") | }, | { | "_id" : ObjectId("62b619e0d3af55ae13afb1d0") | }, | { | "_id" : ObjectId("62b619e0d3af55ae13afb1d1") | }, | { | "_id" : ObjectId("62b619e0d3af55ae13afb1d2") | } | ] `---- ,---- | [ | { | "_id" : ObjectId("62b619e0d3af55ae13afb1cf") | }, | { | "_id" : ObjectId("62b619e0d3af55ae13afb1d0") | }, | { | "_id" : ObjectId("62b619e0d3af55ae13afb1d1") | }, | { | "_id" : ObjectId("62b619e0d3af55ae13afb1d2") | } | ] `----
showRecordId() documentation → https://www.mongodb.com/docs/v6.0/reference/method/cursor.showRecordId/
PS: the issue also doesn’t seem to be SBE or classic engine specific.
- related to
-
DOCS-15547 Fix example in documentation of 'showRecordId()' cursor method
- Closed