-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat(spanner): add support of checking row not found errors from ReadRow and ReadRowUsingIndex #10405
Conversation
b550e3b
to
a8e5581
Compare
…Row and ReadRowUsingIndex
a8e5581
to
bacee62
Compare
spanner/errors.go
Outdated
@@ -26,6 +27,11 @@ import ( | |||
"google.golang.org/grpc/status" | |||
) | |||
|
|||
var ( | |||
// ErrRecordNotFound record not found error | |||
ErrRecordNotFound = errors.New("record not found") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ErrRowNotFound
corresponds better with the original error message row not found...
ErrRecordNotFound = errors.New("record not found") | |
ErrRowNotFound = errors.New("record not found") |
spanner/transaction.go
Outdated
@@ -373,7 +377,7 @@ func (t *txReadOnly) ReadRowWithOptions(ctx context.Context, table string, key K | |||
// ReadRowUsingIndex reads a single row from the database using an index. | |||
// | |||
// If no row is present with the given index, then ReadRowUsingIndex returns an | |||
// error where spanner.ErrCode(err) is codes.NotFound. | |||
// error(spanner.ErrRecordNotFound) where spanner.ErrCode(err) is codes.NotFound. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here: Maybe add an example in the comments for how users should check for this specific error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
c04025c
to
bda801f
Compare
spanner/transaction.go
Outdated
// | ||
// To check if the error is spanner.ErrRecordNotFound: | ||
// | ||
// if errors.Is(err, ErrRecordNotFound) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// if errors.Is(err, ErrRecordNotFound) { | |
// if errors.Is(err, ErrRowNotFound) { |
spanner/transaction.go
Outdated
// | ||
// To check if the error is spanner.ErrRecordNotFound: | ||
// | ||
// if errors.Is(err, ErrRecordNotFound) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// if errors.Is(err, ErrRecordNotFound) { | |
// if errors.Is(err, ErrRowNotFound) { |
spanner/transaction.go
Outdated
// error where spanner.ErrCode(err) is codes.NotFound. | ||
// error(spanner.ErrRowNotFound) where spanner.ErrCode(err) is codes.NotFound. | ||
// | ||
// To check if the error is spanner.ErrRecordNotFound: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// To check if the error is spanner.ErrRecordNotFound: | |
// To check if the error is spanner.ErrRowNotFound: |
spanner/transaction.go
Outdated
// | ||
// To check if the error is spanner.ErrRecordNotFound: | ||
// | ||
// if errors.Is(err, ErrRecordNotFound) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// if errors.Is(err, ErrRecordNotFound) { | |
// if errors.Is(err, ErrRowNotFound) { |
1838660
to
02d99fd
Compare
Fixes: #10031
Customers can check row not found cases with below condition