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

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

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Minor - P4
    • Resolution: Fixed
    • None
    • v1.3.11
    • manual
    • None
    • 8
    • true

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:
                7 years, 47 weeks, 6 days ago