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

array element selection syntax returns wrong result

    Details

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

      Description

      Tried the following:

      db = db.getSiblingDB('qa');
      db.foo.save({b:[1, 2, 3, 4]});
      db.foo.find({}, {"b.2":1});

      Result is an empty array:

      { "_id" : ObjectId("4f5f95b285228a256ddccf7e"), "b" : [ ] }

      Is that supposed to work, or are we just not detecting the unsupported syntax?

      Since it has to be quoted anyway, it would be nicer if this worked:

      > db.foo.find({}, {"b[2]":1});
      { "_id" : ObjectId("4f5f95b285228a256ddccf7e") }

        Issue Links

          Activity

          • Comments
          Hide
          cwestin Chris Westin added a comment -

          Also: if this is supposed to work, I couldn't find any reference to it in our docs. All I could find was doc for $slice: http://www.mongodb.org/display/DOCS/Retrieving+a+Subset+of+Fields#RetrievingaSubsetofFields-RetrievingaSubrangeofArrayElements .

          Show
          cwestin Chris Westin added a comment - Also: if this is supposed to work, I couldn't find any reference to it in our docs. All I could find was doc for $slice: http://www.mongodb.org/display/DOCS/Retrieving+a+Subset+of+Fields#RetrievingaSubsetofFields-RetrievingaSubrangeofArrayElements .

            People

            • Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: