-
Notifications
You must be signed in to change notification settings - Fork 118
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
tapdb: fix bug w.r.t null bool handling, allow InsertScriptKey to allow flipping known to true #1185
Conversation
951109c
to
2b288da
Compare
Pull Request Test Coverage Report for Build 11808369738Details
💛 - Coveralls |
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 a lot for the fix!
This only works for bools that are always set? Vs. other bools that are optional. I think this would be correct for any spot where we insert data created with |
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.
Looks reasonable, though I wonder if we can have an equivalent fix just by changing the existing query; commented separately.
c27ea4d
to
922448d
Compare
922448d
to
08c182d
Compare
In this commit, we add a new `extractBool` helper function. In an upcoming commit, we'll use this to fix incorrect usage of the `sql.NullBool` type.
In this commit, we fix some incorrect handling on null bool in SQL, that looks to be mostly benign. Before this commit, instead of doing `.Bool`, we did `.Valid`. The latter is only useful to check if something is zero, or NULL. In this case, we can just go with the bool value directly.
In this commit, we update `InsertScriptKey` to allow flipping known to true, if it was false before. This is useful as at times a script key from a smart contract might have been inserting on disk, but with declared known as false. Then if we tried to insert it again, with known as true, the upsert logic would end up making no change on disk.
08c182d
to
d453f81
Compare
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.
LGTM 🎉
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.
LGTM 💯
In this commit, we fix some incorrect handling on null bool in SQL, that
looks to be mostly benign. Before this commit, instead of doing
.Bool
,we did
.Valid
. The latter is only useful to check if something iszero, or NULL. In this case, we can just go with the bool value
directly.
Then, we update
InsertScriptKey
to allow flipping known totrue, if it was false before.
This is useful as at times a script key from a smart contract might have
been inserting on disk, but with declared known as false. Then if we
tried to insert it again, with known as true, the upsert logic would end
up making no change on disk.
Note that without the initial bug fix, the test added in the last commit
would fail.