Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return command error from findAndModify #2646

Merged
merged 17 commits into from
May 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clean up
  • Loading branch information
chilagrow committed May 17, 2023
commit ac2410875a13f97017e9cded29b816b5177d463d
13 changes: 4 additions & 9 deletions internal/handlers/common/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,8 @@ func UpdateDocument(command string, doc, update *types.Document) (bool, error) {

path, err = types.NewPathFromString(key)
if err != nil {
return false, commonerrors.NewWriteErrorMsg(
commonerrors.ErrEmptyName,
fmt.Sprintf("Cannot apply $unset to a value of non-numeric type. "+
"{_id: %s} has the field '%s' of non-numeric type object",
must.NotFail(doc.Get("_id")),
key,
),
)
// ValidateUpdateOperators checked already $unset contains valid path.
panic(err)
}

if doc.HasByPath(path) {
Expand Down Expand Up @@ -938,7 +932,8 @@ func validateOperatorKeys(command string, docs ...*types.Document) error {
return nil
}

// extractValueFromUpdateOperator gets operator "op" value and returns WriteError error if it is not a document.
// extractValueFromUpdateOperator gets operator "op" value and returns CommandError for `findAndModify`
// WriteError error other commands if it is not a document.
// For example, for update document
//
// bson.D{
Expand Down