[SERVER-5369] $project exclusion doubles _id field in console output Created: 22/Mar/12  Updated: 11/Jul/16  Resolved: 26/Mar/12

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 2.1.0
Fix Version/s: 2.1.1

Type: Bug Priority: Minor - P4
Reporter: Doug Hudson Assignee: Chris Westin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

uname -a
Linux 3.0.0-16-generic #29-Ubuntu SMP Tue Feb 14 12:48:51 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

> db.serverBuildInfo()
{
"version" : "2.1.0",
"gitVersion" : "d674c681170337e3dfc34ae796b06fdde5ac05dd",
"sysInfo" : "Linux ip-10-110-9-236 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_41",
"versionArray" : [
2,
1,
0,
0
],
"bits" : 64,
"debug" : false,
"maxBsonObjectSize" : 16777216,
"ok" : 1
}


Operating System: Linux
Participants:

 Description   

> db.test.save(

{a:1,b:2}

)
> db.test.save(

{a:3,b:4}

)

> db.test.find()

{ "_id" : ObjectId("4f6ba4a90a07b1052bfdb5e0"), "a" : 1, "b" : 2 } { "_id" : ObjectId("4f6ba4b40a07b1052bfdb5e1"), "a" : 3, "b" : 4 }

> db.test.aggregate({$project:{a:0}})
{
"result" : [

{ "_id" : ObjectId("4f6ba4a90a07b1052bfdb5e0"), "_id" : ObjectId("4f6ba4a90a07b1052bfdb5e0"), "b" : 2 }

,

{ "_id" : ObjectId("4f6ba4b40a07b1052bfdb5e1"), "_id" : ObjectId("4f6ba4b40a07b1052bfdb5e1"), "b" : 4 }

],
"ok" : 1
}

Repeated attribute is obviously not possible, so this seems very minor, but is a bit unexpected to see and object come back like this.



 Comments   
Comment by auto [ 20/Jul/12 ]

Author:

{u'date': u'2012-07-14T12:04:12-07:00', u'email': u'mathias@10gen.com', u'name': u'Mathias Stearn'}

Message: Rewrite ExpressionObject

The main difference between this version and the old is that the following
three $pipelines will produce the same output (SERVER-6468):

{'a.b': 1}

// classic inclusion
{a:

{b: 1}

// nested inclusion

{'a.b': '$a.b'}

// dotted FieldPathExpression
{a:

{b: '$a.b'}

// nested FieldPathExpression

Additionally support for exclusion of fields other than _id has been
removed for 2.2 (SERVER-6361)

Other related bugs:
SERVER-6177 better error for

{a:1, 'a.b':1}

SERVER-6181 support for computed _id
SERVER-6184 support {'a.b': 1, a:{c:1}} in either order

Remaining TODOs:
Re-enable the isSimple() method
See if this can be used more directly by $group to support nested fields (SERVER-6198)

Disabled test for SERVER-5369 because it depends on ability to exclude
arbitrary fields.
Branch: master
https://github.com/mongodb/mongo/commit/ec18db98680d31b120350ad45d5f74095125e9a5

Comment by auto [ 06/Jul/12 ]

Author:

{u'date': u'2012-07-05T13:14:33-07:00', u'email': u'dannenberg.matt@gmail.com', u'name': u'Matt Dannenberg'}

Message: fix SERVER-5369 test to actually test something
Branch: master
https://github.com/mongodb/mongo/commit/e327b6788891bc4bcfe96459c01d8a4e784928f5

Comment by auto [ 26/Mar/12 ]

Author:

{u'login': u'cwestin', u'name': u'U-tellus\\cwestin', u'email': u'cwestin@10gen.com'}

Message: SERVER-5369 don't show _id twice for exclusionary mode
Branch: master
https://github.com/mongodb/mongo/commit/2bd824ce85427664a68913df01cb8ea2c6bdf93a

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