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

findAndModify can't handle {fields: {_id: 0}}

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.8.3
    • Component/s: Querying, Write Ops
    • None
    • Environment:
      ubuntu 11.04
    • ALL

      when using findAndModify and trying to remove the id field with {fields: {_id, 0}}
      I'm getting an error:
      uncaught exception: findAndModifyFailed failed: "exception: assertion db/../util/../util/../db/../bson/bsonobjbuilder.h:112"

      To reproduce:
      db.jobs.save( {
      name: "Biz report",
      inprogress: false, priority:1,
      tasks : [ "run sales report", "email report" ]
      } );

      // without fields it works:
      job = db.jobs.findAndModify({
      query:

      {name: "Biz report"}

      ,
      sort :

      {priority:-1}

      ,
      update: {$set: {inprogress: true, started: new Date()}},
      new: true
      });

      // works with fields too
      job = db.jobs.findAndModify({
      query:

      {name: "Biz report"}

      ,
      sort :

      {priority:-1}

      ,
      update: {$set: {inprogress: true, started: new Date()}},
      fields:

      {name: 1}

      ,
      new: true
      });

      // find works when using {_id: 0} in fields:
      db.jobs.find(

      {name: "Biz report"}

      ,

      {name:1, _id: 0}

      )

      // findAndModify fail when using {_id, 0} in fields:
      job = db.jobs.findAndModify({
      query:

      {name: "Biz report"}

      ,
      sort :

      {priority:-1}

      ,
      update: {$set: {inprogress: true, started: new Date()}},
      fields:

      {name: 1, _id: 0}

      ,
      new: true
      });

            Assignee:
            Unassigned Unassigned
            Reporter:
            pablo pablo platt
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: