Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-8805

aggregation $within command: exception thrown

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.4.0-rc1
    • Component/s: Shell
    • Environment:
      QA
    • ALL
    • Hide

      run on shell the following command:

      var single_value_box = [[1]];
      var aggRes = col.aggregate( { $match: { loc: {$within: {$box: single_value_box}}}});
      
      Show
      run on shell the following command: var single_value_box = [[1]]; var aggRes = col.aggregate( { $match: { loc: {$within: {$box: single_value_box}}}});

      I believe this sticky code left for some js debugging:

      collections.js
      DBCollection.prototype.aggregate = function( ops ) {
          
          var arr = ops;
          
          if (!ops.length) {
              arr = [];
              for (var i=0; i<arguments.length; i++) {
                  arr.push(arguments[i]);
              }
          }
      
          var res = this.runCommand("aggregate", {pipeline: arr});
          if (!res.ok) {
              printStackTrace();
              throw "aggregate failed: " + tojson(res);
          }
          return res;
      }
      

      redbeard0531 probably missed it:

      git blame src/mongo/shell/collection.js | head -901 | tail -18
      5115bf67 shell/collection.js           (Eliot Horowitz  2011-12-09 04:20:54 -0500  884) DBCollection.prototype.aggregate = function( ops ) {
      5115bf67 shell/collection.js           (Eliot Horowitz  2011-12-09 04:20:54 -0500  885)     
      5115bf67 shell/collection.js           (Eliot Horowitz  2011-12-09 04:20:54 -0500  886)     var arr = ops;
      5115bf67 shell/collection.js           (Eliot Horowitz  2011-12-09 04:20:54 -0500  887)     
      68f6dcd2 src/mongo/shell/collection.js (Mathias Stearn  2012-12-18 13:26:26 -0500  888)     if (!ops.length) {
      5115bf67 shell/collection.js           (Eliot Horowitz  2011-12-09 04:20:54 -0500  889)         arr = [];
      68f6dcd2 src/mongo/shell/collection.js (Mathias Stearn  2012-12-18 13:26:26 -0500  890)         for (var i=0; i<arguments.length; i++) {
      68f6dcd2 src/mongo/shell/collection.js (Mathias Stearn  2012-12-18 13:26:26 -0500  891)             arr.push(arguments[i]);
      5115bf67 shell/collection.js           (Eliot Horowitz  2011-12-09 04:20:54 -0500  892)         }
      5115bf67 shell/collection.js           (Eliot Horowitz  2011-12-09 04:20:54 -0500  893)     }
      68f6dcd2 src/mongo/shell/collection.js (Mathias Stearn  2012-12-18 13:26:26 -0500  894) 
      68f6dcd2 src/mongo/shell/collection.js (Mathias Stearn  2012-12-18 13:26:26 -0500  895)     var res = this.runCommand("aggregate", {pipeline: arr});
      68f6dcd2 src/mongo/shell/collection.js (Mathias Stearn  2012-12-18 13:26:26 -0500  896)     if (!res.ok) {
      68f6dcd2 src/mongo/shell/collection.js (Mathias Stearn  2012-12-18 13:26:26 -0500  897)         printStackTrace();
      68f6dcd2 src/mongo/shell/collection.js (Mathias Stearn  2012-12-18 13:26:26 -0500  898)         throw "aggregate failed: " + tojson(res);
      68f6dcd2 src/mongo/shell/collection.js (Mathias Stearn  2012-12-18 13:26:26 -0500  899)     }
      68f6dcd2 src/mongo/shell/collection.js (Mathias Stearn  2012-12-18 13:26:26 -0500  900)     return res;
      5115bf67 shell/collection.js           (Eliot Horowitz  2011-12-09 04:20:54 -0500  901) } }
      
      

      This should not throw an exception but an error message.

      N.

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            norberto.leite Norberto Fernando Rocha Leite (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: