Allow individual updates to accept parameters for non-pipeline updates

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Query Language
    • Query Optimization
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Currently in the update command, if you specify 'c' in the individual element of the 'updates' array, and the update description 'u' is not a pipeline-update, you'll get an error "code: 51198, errmsg: 'Constant values may only be specified for pipeline updates'".

      db.people.insertOne({name: "Andy"})
      db.runCommand(
         {
           update: "people",
           updates: [
             { 
              q: { $expr: { $eq: [ "$name", "$$nameVar" ] } }, 
              u: {  $inc: { score: 1 } }, 
              multi: true,
              c: {nameVar: "Andy"}
              }
           ]
         }
      )
      

      This prevents using parameters defined in 'c' in the 'q' filter part of the update.
      Also, it is not consistent with 'let' where you can set parameters on the command level, and it will not produce an error for the non-pipeline updates.

      db.runCommand(
         {
           update: "people",
           updates: [
             { 
              q: { $expr: { $eq: [ "$name", "$$nameVar" ] } }, 
              u: {  $inc: { score: 1 } }, 
              multi: true
              }
           ],
           let: {nameVar: "Andy"}
         }
      )
      

              Assignee:
              [DO NOT USE] Backlog - Query Optimization
              Reporter:
              Katya Kamenieva
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated: