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

Accessing array element with invalid methods

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 5.0.9, 4.4.15
    • Component/s: None
    • Labels:
      None
    • ALL

      As we know proper way to access a array element in aggregation runtime is via using `$arrayElemAt` operator. but in situations which I have tried with invalid methods like `$$arr.0` or `$$arr.[0]` I expect to get some kind of error or maybe similar behaviour as using `$$arr[0]` which does nothing but except with two latter methods of accessing array element I would get an empty array as result which I consider to be some sort of bug or invalidAccessMethodWhichDoesSomethingWierd:something. Or... there is some unknown defined behaviour which I'm not aware of!

      Currently I checked this with mongod version 4.4(for sure) and 5.0.9(I think so...) and result was the same.

      As you see in the picture on right terminal I set with 3 methods which 2 of them are invalid but In those 2 invalid situations I get different responses. neither of them throws any error...

            Assignee:
            yuan.fang@mongodb.com Yuan Fang
            Reporter:
            pooyankhan@gmail.com Pooyan Khanjankhani
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: