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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Duplicate
    • 1.8.3
    • None
    • Querying, Write Ops
    • None
    • ubuntu 11.04
    • ALL

    Description

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

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: