Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-68213

Stop generating an OP_QUERY-style query representation in the shell's find implementation

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.1.0-rc0
    • Affects Version/s: None
    • Component/s: Shell
    • Labels:
      None
    • Minor Change
    • QE 2022-07-25, QE 2022-08-08, QE 2022-08-22

      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.

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: