Uploaded image for project: 'Core Server'
  1. Core Server
  2. 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

    • ALL

      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' } } ) );
      

            Assignee:
            aaron Aaron Staple
            Reporter:
            aaron Aaron Staple
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: