[SERVER-3757] findAndModify can't handle {fields: {_id: 0}} Created: 04/Sep/11  Updated: 07/Mar/14  Resolved: 04/Sep/11

Status: Closed
Project: Core Server
Component/s: Querying, Write Ops
Affects Version/s: 1.8.3
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: pablo platt Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

ubuntu 11.04


Issue Links:
Duplicate
duplicates SERVER-2626 Excluding _id field doesn't work with... Closed
Operating System: ALL
Participants:

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



 Comments   
Comment by Scott Hernandez (Inactive) [ 04/Sep/11 ]

Dup of SERVER-2626

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