[SERVER-6434] Query projection behavior shouldn't depend on order of fields Created: 13/Jul/12  Updated: 06/Dec/22  Resolved: 13/Apr/16

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

Type: Bug Priority: Major - P3
Reporter: Mathias Stearn Assignee: Backlog - Query Team (Inactive)
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-6527 in projection implementation, dotted ... Closed
Assigned Teams:
Query
Operating System: ALL
Participants:

 Description   

I don't know which is correct, but they should do the same thing (possibly both erroring out).

> db.foo.find()
{ "_id" : ObjectId("4fff661614a4344a2507267c"), "a" : { "b" : { "c" : 1 } } }
{ "_id" : ObjectId("4fff73ad14a4344a2507267d"), "a" : [ { "b" : [ { "c" : 1 } ] } ] }
> db.foo.find({}, {'a':1, 'a.c':1})
{ "_id" : ObjectId("4fff661614a4344a2507267c"), "a" : { } }
{ "_id" : ObjectId("4fff73ad14a4344a2507267d"), "a" : [ { } ] }
> db.foo.find({}, {'a.c':1, a:1})
{ "_id" : ObjectId("4fff661614a4344a2507267c"), "a" : { "b" : { "c" : 1 } } }
{ "_id" : ObjectId("4fff73ad14a4344a2507267d"), "a" : [ { "b" : [ { "c" : 1 } ] } ] }



 Comments   
Comment by J Rassi [ 13/Apr/16 ]

Closing as a dup of SERVER-6527.

Comment by David Storch [ 13/Nov/13 ]

Here's a slightly simplified way to reproduce:

> c.drop()
true
> c.insert({a: {b: 1}})
{ "ok" : 1, "n" : 1 }
> c.find({}, {a: 1, 'a.c': 1})
{ "_id" : ObjectId("5283b11d52b8ac952f2d10eb"), "a" : {  } }
> c.find({}, {'a.c': 1, a: 1})
{ "_id" : ObjectId("5283b11d52b8ac952f2d10eb"), "a" : { "b" : 1 } }

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