[SERVER-46670] Document the behavior when projection includes fields "a" and "a.b" Created: 06/Mar/20  Updated: 09/Mar/20  Resolved: 09/Mar/20

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

Type: Improvement Priority: Major - P3
Reporter: Yao Wei Assignee: Ian Boros
Resolution: Duplicate Votes: 0
Labels: qexec-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-6527 in projection implementation, dotted ... Closed
Sprint: Query 2020-03-23
Participants:

 Description   

We found out that when projection includes "a" and "a.b", that is, parent and child document are both in the projection, the order in BSON Document is prominent.  For example:

These two are equivalent:

db.document.find({}, {"a.b":1, "a":1})
db.document.find({}, {"a":1})

and these two:

db.document.find({}, {"a":1, "a.b":1})
db.document.find({}, {"b":1})

I am wondering whether it is undocumented behavior, or it should be able to include the parent document regardless of the order.



 Comments   
Comment by Ian Boros [ 09/Mar/20 ]

Hello mwei,

I believe this is more or less a duplicate of SERVER-6527. You are absolutely right that this behavior is strange (and undesirable). Fortunately, this problem has been fixed in master, so versions of mongo 4.4 and later will report an error when any paths which overlap with one another are projected.

Feel free to comment here if you have any questions! I will close this ticket as a duplicate of SERVER-6527.

IB

Comment by Yao Wei [ 06/Mar/20 ]

Correction on the descriptions. These two are equivalent, instead of the latter two in the issue description:

db.document.find({}, {"a":1, "a.b":1})
db.document.find({}, {"a.b":1})

Generated at Thu Feb 08 05:12:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.