-
Notifications
You must be signed in to change notification settings - Fork 137
tapdb: allow reinsertion of an existing address to the book #1549
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
Conversation
Pull Request Test Coverage Report for Build 15166568904Details
💛 - Coveralls |
guggero
left a comment
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.
Nice! One request and a nit, otherwise LGTM.
| -- RETURNING id to work on the existing row. | ||
| taproot_output_key = excluded.taproot_output_key | ||
| WHERE | ||
| addrs.version = excluded.version |
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.
Hmm, interesting approach.
So this now returns unable to insert addr: sql: no rows in result set if some fields mismatch. Sounds good to me, but I think we should catch that on the RPC server and return a more user friendly error. Otherwise it's hard to understand what's wrong.
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.
ptal
tapdb/addrs_test.go
Outdated
|
|
||
| // Now change the amount, which upon upsert should trigger an error. | ||
| addrs[0].Amount += 1 | ||
| require.Error(t, addrBook.InsertAddrs(ctx, addrs[0])) |
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.
nit: require.ErrorIs(t, addrBook.InsertAddrs(ctx, addrs[0]), sql.ErrNoRows)?
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.
ptal
With this change we allow "upserting" an address. This is useful in the case when a tapd user might not know if they've created a specific address already (as there's no easy way to look it up).
guggero
left a comment
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.
Thanks, LGTM 🎉
With this change we allow "upserting" an address. This is useful in the case when a tapd user might not know if they've created a specific address already (as there's no easy way to look it up).