Using the method `connect` in a script will as a side effect update global `db` with the new connection. This is not how connect is described in the documentation https://docs.mongodb.com/manual/reference/method/connect/.
The bug is introduced in version r3.3.12, in commit 88b540f0c14c7ab8af708aecc4cd6df83081b32e.
On line 235 you see the connection is stored in `db`. Because the declaration of db is removed (old line 240) the new connection is stored in the global `db`. The global `db` is used for the connection where the script is running.
- related to
-
SERVER-22382 mongo shell should accept mongodb:// URI for --host
- Closed