storage/inmemory: fix Patch() error handling (#4838)

The Patch() method was intended to skip any records that do not
currently exist. However, currently inmemory.Backend.Patch() will return
ErrNotFound if the last record in the records slice is not found (it
will ignore any other previous records that are not found).

Update the error handling logic here to be consistent with the postgres
backend, and add a unit test to exercise this case.
This commit is contained in:
Kenneth Jenkins 2023-12-07 12:21:10 -08:00 committed by GitHub
parent c01d0e045d
commit a771b82a72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View file

@ -269,12 +269,12 @@ func (backend *Backend) Patch(
// Skip any record that does not currently exist.
continue
} else if err != nil {
return
return serverVersion, patchedRecords, err
}
patchedRecords = append(patchedRecords, record)
}
return
return serverVersion, patchedRecords, nil
}
// patch updates the specified fields of an existing record, assuming the RWMutex is held.