[SERVER-6861] pipeline parser allows multiple pipeline stage fields in a stage spec object, uses the last one only instead of triggering a parse error Created: 27/Aug/12  Updated: 11/Jul/16  Resolved: 10/Sep/12

Status: Closed
Project: Core Server
Component/s: Aggregation Framework, Usability
Affects Version/s: None
Fix Version/s: 2.3.0

Type: Bug Priority: Major - P3
Reporter: Aaron Staple Assignee: Aaron Staple
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Operating System: ALL
Participants:

 Description   

Observed behavior: If multiple pipeline stages are specified in a single object (eg. { $project:

{ ... }, $sort:{ ... }

}, the last one is used and earlier ones are dropped.

Expected behavior: Only one pipeline stage spec is allowed in a pipeline spec object. Otherwise a parse error is triggered.

Currently multiple pipeline stages are properly specified as separate objects within an array (eg. [ { $project:

{ ... } }, { $sort:{ ... }

} ] ).

Test

c = db.c;
c.drop();
 
c.save( { a:1 } );
// Runs as a $project.
printjson( c.aggregate( { $project:{ z:'$a' } } ) );
// Runs as a $sort.
printjson( c.aggregate( { $project:{ z:'$a' }, $sort:{ a:1 } } ) );
// Runs as a $group.
printjson( c.aggregate( { $project:{ z:'$a' }, $sort:{ a:1 }, $group:{ _id:'$a' } } ) );



 Comments   
Comment by auto [ 09/Sep/12 ]

Author:

{u'date': u'2012-09-09T14:07:03-07:00', u'email': u'aaron@10gen.com', u'name': u'Aaron'}

Message: SERVER-SERVER-6861 Validate that pipeline stage specification objects consist of a single field. Clean up pipeline stage parsing.
Branch: master
https://github.com/mongodb/mongo/commit/15b70ce895fd2e56d65988470854014eb735ea3d

Comment by Aaron Staple [ 27/Aug/12 ]

This is a usability concern, as someone can easily mess up and write their aggregation spec incorrectly. And they won't get an error.

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