Details
-
Bug
-
Status: Closed
-
Major - P3
-
Resolution: Duplicate
-
3.3.5, 3.4.3
-
None
-
None
-
Fully Compatible
-
ALL
-
-
Platforms 2017-08-21
Description
The MongoDB shell supports accessing a cursor's elements via array access, without first converting the cursor into an array: db.items.find(...)[0]
However, this might return 'undefined' even when the cursor actually contains elements.
I attached a script that demonstrates the issue.
Some notes:
- The problem disappears when using the toArray-function.
- Direct array access on a cursor seems to be not documented. However, because it is so intuitive and works in most cases, it is probably often used.
- When running into the issue, the shell seems to be in an inconsistent state. As the 'inconsistent.js' script demonstrates, an if-clause with identical 'then' and 'else' branches might return different results depending on the condition.
Attachments
Issue Links
- duplicates
-
SERVER-30362 JavaScript DBCollection.toString() stops working
-
- Closed
-
- related to
-
SERVER-30362 JavaScript DBCollection.toString() stops working
-
- Closed
-
-
SERVER-23358 Upgrade SpiderMonkey to 45.0.2 ESR
-
- Closed
-