Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-3874

Add warning about undefined behavior cases for positional projection operator ($)

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • v1.3.11
    • Affects Version/s: None
    • Component/s: manual
    • Labels:
      None

      Refers to SERVER-14662.

      The behavior of the positional projection operator is undefined when there are multiple predicates over the projected array which are not joined by an $elemMatch. (Say the positional projection is {"a.b.$": 1}, then the "projected array" would be "a.b".)

      The behavior is undefined in that you can't count on which array element will be returned by the projection. One of the predicates over the projected array will be used to match the nested document to project; if there is more than one predicate, then you don't know which one will be used for the match.

      Let's add a warning to the positional projection documentation in order to discourage users from relying on this undefined behavior.

            Assignee:
            andrew.aldridge@mongodb.com Andrew Aldridge
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              9 years, 42 weeks, 4 days ago