Make update array filters agnostic to variable name change

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Won't Fix
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Integration
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      samuel.mercier@mongodb.com noted on Friday that it's possible to vary identifier used in an array filter to change the query shape, even though such a change doesn't change the semantics of the update statement.

      Example: these two update statements behave identically:

      { 
              q: { x: 3 },  
              u: {$inc: { "grades.$[t].questions.score": 2 } },
              arrayFilters: [ { "t.type": "quiz" }  ], 
      }
      
      { 
              q: { x: 3 },  
              u: {$inc: { "grades.$[v].questions.score": 2 } },
              arrayFilters: [ { "v.type": "quiz" }  ], 
      }
      

      In these two statements, only the variable in the array filter is different, t vs v. But they do exactly the same thing.

      If these two statements behave identically, it stands to reason that they should have identical query shapes.

      Note: a similar case exists for let expressions and aggregation pipelines, but we don't currently normalize based on variable names there either. In any case, it seems worth a discussion what the right behavior is here.

            Assignee:
            Unassigned
            Reporter:
            Chris Wolff
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: