Skip to content

add more useful error messages for invalid field names#460

Closed
mjrb wants to merge 1 commit intomongodb:masterfrom
mjrb:master
Closed

add more useful error messages for invalid field names#460
mjrb wants to merge 1 commit intomongodb:masterfrom
mjrb:master

Conversation

@mjrb
Copy link

@mjrb mjrb commented Mar 4, 2018

This fixes https://jira.mongodb.org/browse/JAVA-2114. when you do an update and forget to put something like $set or $inc in the query or have an other wise malformed update query the error message wasn't very helpful even if it was a silly error. this pull request checks which field name validator failed and gives an appropriate error message.

@imthereddwarf
Copy link

IMHO this is incorrect validation. In the mongo client you can update without needing $set, db.collection.update( { _id: key}, { _id: key, field: value } ) works fine, but fails in the java driver with the "Invalid BSON field name _id" exception. The same error occurs with upsert=true and having to use $set with an upsert makes no sense. So the correct fix is to remove this validation altogether.

@jyemin
Copy link
Collaborator

jyemin commented May 21, 2022

Closing due to inactivity.

@jyemin jyemin closed this May 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants