Clubhouse-148415: fix issue with interface nil not being nil#10
Merged
jfbramlett merged 1 commit intomasterfrom Aug 18, 2021
Merged
Conversation
|
This pull request has been linked to Clubhouse Story #148415: Reloading an existing model does not update timestamp fields. |
alexbednarczyk
approved these changes
Aug 18, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Go interfaces...my initial attempt worked fine in some cases but didn't cover how we actually use this with our db queries. We create an array of "blank" interfaces that can hold any value (for Scanning into) - this results in one of those kind of weird situations in which a nil value is not really a nil so the checks I had were not working correctly.
This PR expands on the check to determine if the value is nil, I broke it into singular checks to make it a bit easier to debug and see which condition is being met. In this case I need to look at what the interface is referencing to determine if the value is nil (the check inside
if reflect.ValueOf(val).Kind() == reflect.Ptr).Its a bit ugly but so is Go reflection in general.