[SERVER-5299] array element selection syntax returns wrong result Created: 13/Mar/12  Updated: 15/Feb/13  Resolved: 26/Nov/12

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Daniel Pasette (Inactive) Assignee: Unassigned
Resolution: Duplicate Votes: 3
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-1831 Using dot-notation to field-select an... Backlog
Related
is related to SERVER-4589 aggregation: need an array indexing ... Closed
Operating System: ALL
Participants:

 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") }



 Comments   
Comment by Chris Westin [ 13/Mar/12 ]

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 .

Generated at Thu Feb 08 03:08:29 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.