-
Notifications
You must be signed in to change notification settings - Fork 19
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
add similar unique violation check as sql for spanner #287
Conversation
Codecov ReportPatch coverage:
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## master #287 +/- ##
==========================================
+ Coverage 75.80% 75.88% +0.07%
==========================================
Files 28 28
Lines 926 929 +3
==========================================
+ Hits 702 705 +3
Misses 178 178
Partials 46 46
☔ View full report in Codecov by Sentry. |
Are we going to close #286 ? This can be released as v0.41.0 since it adds to the public API. Please commit the changelog update in a standalone commit and |
Yeah, I wasn't in the internal Sounds good @adamdecaf ; I'm guessing you're referring to something like this #266 for the |
Yea but just commit the changelog to |
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.
approved w/ two minor comments
database/spanner.go
Outdated
match := strings.Contains(err.Error(), "Failed to insert row with primary key") | ||
return match || spanner.ErrCode(err) == codes.AlreadyExists |
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.
match := strings.Contains(err.Error(), "Failed to insert row with primary key") | |
return match || spanner.ErrCode(err) == codes.AlreadyExists | |
return spanner.ErrCode(err) == codes.AlreadyExists || | |
strings.Contains(err.Error(), "AlreadyExists") | |
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
I squashed the commits since there was some cleanup. Do we plan on adding more before cutting a release? |
While we could go down the rabbit hole of mapping all the errors, I think at least for now what we have is sufficient because we’re trying to replicate what we have existing for mySQL; there is the other sql verification Edit: There is one minor thing we can do which is update cc @vxio |
@gyao852 oh right, let's update that method (database::UniqueViolations), i didn't realize that existed.. thanks! |
Sounds good. Let's get that patch in and can cut a release. |
Changes:
mysql::MySQLUniqueViolation
, addedspanner::SpannerUniqueViolation
that look at the error code or message to deduce if we have a duplicate error.Note:
spanner.Error
will be deprecated in the future, replaced withAPIError
. I added tests for both responses from client.