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

warn when more than one array is used in a query with $ projection operator

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Querying
    • Labels:
      None

      Description

      When you query for a value on each of two arrays, both with positional operators, the $ projection operator can get pretty confused but smoothly performs the wrong operation.

      Steps to reproduce:

      Perform the following operations in the shell:

      db.foo.insert( { a : [5, 6, 7, 8], b : [ 11, 12, 13, 14] } )
      db.foo.find( { a : 7, b : 11 }, { "a.$" : 1 , _id : 0 } 

      Expected result:

      { "a" : 7 }

      or an exception

      Actual result :

      { "a" : 5 }

      Related documentation:

      The following doc tells me not to do exactly what I did: http://docs.mongodb.org/manual/reference/operator/projection/positional/#proj._S_

      "Only one array field can appear in the query document; i.e. the following query is incorrect:" (then the example shows me exactly what I did), but this is clearly a case where either an exception should be thrown, or else the $ operator should be made smarter.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              hari.khalsa@10gen.com hari.khalsa@10gen.com
              Reporter:
              william.cross William Cross
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: