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
add comments
  • Loading branch information
chilagrow committed May 17, 2023
commit 686022379519d40428afaa0ffee282b498a00ec5
5 changes: 4 additions & 1 deletion internal/handlers/common/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ import (
// UpdateDocument updates the given document with a series of update operators.
// Returns true if document was changed.
// To validate update document, must call ValidateUpdateOperators before calling UpdateDocument.
// TODO findAndModify returns CommandError https://github.com/FerretDB/FerretDB/issues/2440
// UpdateDocument returns CommandError for findAndModify case-insensitive command name,
// WriteError for other commands.
func UpdateDocument(command string, doc, update *types.Document) (bool, error) {
var changed bool
var err error
Expand Down Expand Up @@ -742,6 +743,8 @@ func processCurrentDateFieldExpression(doc *types.Document, currentDateVal any)
}

// ValidateUpdateOperators validates update statement.
// ValidateUpdateOperators returns CommandError for findAndModify case-insensitive command name,
// WriteError for other commands.
func ValidateUpdateOperators(command string, update *types.Document) error {
var err error
if _, err = HasSupportedUpdateModifiers(command, update); err != nil {
Expand Down