[SERVER-6242] Test breaks in 2.1.2 but passes in 2.1.1 Created: 28/Jun/12  Updated: 24/Jul/12  Resolved: 29/Jun/12

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 2.1.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Christian Amor Kvalheim Assignee: Matt Dannenberg
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

node.js 0.6 and 0.8, mongodb 2.1.2 x64, osx 10.7 lion


Operating System: ALL
Participants:

 Description   

The error is

{ [MongoError: exception: wrong type for field (pipeline) 3 != 4]
  name: 'MongoError',
  errmsg: 'exception: wrong type for field (pipeline) 3 != 4',
  code: 13111,
  ok: 0 }

The document and aggregation pipeline is below

exports.shouldCorrectlyExecuteSimpleAggregationPipelineUsingArguments = function(test) {
  var db = new Db('integration_tests', new Server("127.0.0.1", 27017, 
   {auto_reconnect: false, poolSize: 4, ssl:useSSL}), {native_parser: native_parser});
 
  // Establish connection to db  
  db.open(function(err, db) {
    // Some docs for insertion
    var docs = [{
        title : "this is my title", author : "bob", posted : new Date() ,
        pageViews : 5, tags : [ "fun" , "good" , "fun" ], other : { foo : 5 },
        comments : [
          { author :"joe", text : "this is cool" }, { author :"sam", text : "this is bad" }
        ]}];
   
    // Validate that we are running on at least version 2.1 of MongoDB
    db.admin().serverInfo(function(err, result){
 
      if(parseInt((result.version.replace(/\./g, ''))) >= 210) {
        // Create a collection   
        client.createCollection('shouldCorrectlyExecuteSimpleAggregationPipelineUsingArguments', function(err, collection) {
          // Insert the docs
          collection.insert(docs, {safe:true}, function(err, result) {
            
            // Execute aggregate, notice the pipeline is expressed as function call parameters
            // instead of an Array.
            collection.aggregate(
                { $project : {
                	author : 1,
                	tags : 1,
                }},
                { $unwind : "$tags" },
                { $group : {
                	_id : { tags : 1 },
                	authors : { $addToSet : "$author" }
                }}
              , function(err, result) {
                console.log("===============================================================")
                console.dir(err)
                console.dir(result)
                
                // test.equal(null, err);
                // test.equal('good', result[0]._id.tags);
                // test.deepEqual(['bob'], result[0].authors);
                // test.equal('fun', result[1]._id.tags);
                // test.deepEqual(['bob'], result[1].authors);
                
                db.close();
                test.done();              
            });
          });
        });
      } else {
        db.close();
        test.done();
      }
    });
  });
}



 Comments   
Comment by Christian Amor Kvalheim [ 29/Jun/12 ]

Problem was a change in node 0.8, found it and fixed it in the driver. This ticket is not a bug in 2.1.2

Comment by Daniel Pasette (Inactive) [ 28/Jun/12 ]

@christian can you re-write as js test please?

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