[CXX-1090] Missleading Exception - update_one() Created: 14/Oct/16  Updated: 18/Oct/16  Resolved: 18/Oct/16

Status: Closed
Project: C++ Driver
Component/s: Implementation
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Armin Ball [X] Assignee: David Golden
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Hey!
Referring o the commented line ..// << "ended"...
uncommenting this will lead to the error message in the comment of the same line. The message is not helping.

bsoncxx::document::value filter_document =
document { } << "_id" <<
bsoncxx::oid { strJobID } <<
finalize;
 
bsoncxx::document::value update_doc = document{}
<< "$set"
<< open_document
<< "meta" << bsoncxx::types::b_document{mongoMetaData.view()}
<< "ended" << bsoncxx::types::b_bool { bFinishBecauseOnlyFast }
<< close_document
// << "ended" << bsoncxx::types::b_bool { true }     // mongoc: mongoc_bulk_operation_update_one(): update_one only works with $ operators.
<< "ended" << "true"
<< finalize;
 
...update_one(filter_document.view(), update_doc.view());



 Comments   
Comment by David Golden [ 18/Oct/16 ]

Great, I'm glad it makes sense now. I'll close this ticket.

Comment by Armin Ball [X] [ 18/Oct/16 ]

Now, reading the error message again it makes sence.
"mongoc: mongoc_bulk_operation_update_one(): update_one only works with $ operators."
$set << open_document // is the begin
... // body
close_dosument // is the end.

So the error message is telling me, your out of the $set scope.

My reaction on this was: I do have a $set in my statement, whats so wrong with it? I was do busy to realize, that I'm out of the document.

Comment by David Golden [ 18/Oct/16 ]

I'm a little confused by your update document as to which variation causes the problem. The commented out line would cause the error because you have "ended" and "$set" at the top level of the update document. But you have another "ended" line that isn't commented out that should be causing the same problem. (Is it?) The "ended" within the open/close document should be fine because it's nested.

Can you please dump the update document that gives an error to JSON? E.g. bsoncxx::to_json(update_doc.view())

If you have an update document that works without error, can you dump that as well.

Providing an SSCCE would help.

Separately, when you say "the message is not helping", could you elaborate what you mean?

Comment by Armin Ball [X] [ 15/Oct/16 ]

Versions:
#define MONGOC_VERSION_S "1.3.5"

#define MONGOCXX_VERSION_MAJOR 3
#define MONGOCXX_VERSION_MINOR 0
#define MONGOCXX_VERSION_PATCH 0

Update_document:{
"$set" : {
"meta" : {
"image" :

{ "mimeType" : "image/jpeg", "width" : 2048, "src_codec" : "jpeg", "orientation" : 0, "height" : 1365 }

,
"success" : true
},
"ended" : true
}
}

Comment by David Golden [ 15/Oct/16 ]

Thanks for the report. Some follow up questions:

  • What version of mongocxx?
  • What version of libmongoc?
  • Could you please describe the structure of mongoMetaData?
Generated at Wed Feb 07 22:01:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.