[SERVER-68213] Stop generating an OP_QUERY-style query representation in the shell's find implementation Created: 21/Jul/22  Updated: 29/Oct/23  Resolved: 18/Aug/22

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: None
Fix Version/s: 6.1.0-rc0

Type: Improvement Priority: Major - P3
Reporter: David Storch Assignee: David Storch
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by COMPASS-6036 Investigate changes in SERVER-68213: ... Closed
Related
is related to SERVER-20770 Consolidate the two code paths for ru... Backlog
Backwards Compatibility: Minor Change
Sprint: QE 2022-07-25, QE 2022-08-08, QE 2022-08-22
Participants:

 Description   

The implementation of DBQuery in the shell currently will internally construct an OP_QUERY-style object. Let's take the following simple example query:

const cursor = db.myCollection.find({x: 3}).sort({y: 1}).hint({x: 1});

The cursor object is a DBQuery. The _query property of the DBQuery will be a JS object that looks like this:

{query: {x: 3}, orderby: {y: 1}, $hint: {x: 1}}

This is the format that was formerly accepted in the query field of an OP_QUERY wire protocol message. However, OP_QUERY was deprecated in MongoDB 5.0 and removed in MongoDB 5.1. The OP_QUERY-style payload is summarily converted into a find command by the _convertToCommand() helper.

These shenanigans used to be necessary when the mongo shell supported by OP_QUERY legacy reads and the find command. But now that OP_QUERY reads are a thing of the past, the shell code should be simplified to construct the find command format directly.



 Comments   
Comment by David Storch [ 18/Aug/22 ]

Link to the commit, which just landed: https://github.com/mongodb/mongo/commit/38c6756ee1b0990253afb9fbccaf91b7d985241f

Generated at Thu Feb 08 06:10:12 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.