You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In db.simpleQuery result might get returned with nil value of type *result, but in db.simpleQuery it will be wrapped into Result and will pass != nil check
Query hook receives non nil Result with nil value. This leads to a panic:
Expected Behavior
Code like this don't trigger a nil pointer panic as it have a
e.Result != nil
check.Current Behavior
Part of panic stack trace
Possible Solution
Explicitly set nil for
Result
when*result
is nil.Related article https://codefibershq.com/blog/golang-why-nil-is-not-always-nil
Steps to Reproduce
Here is an example of how nil becomes not nil https://goplay.tools/snippet/DVV1XNz5icn
Context (Environment)
Detailed Description
On first line
res
is a nil. At the last line it assigned a value fromdb.simpleQuery
pg/base.go
Lines 236 to 246 in 51b8018
In
db.simpleQuery
result might get returned with nil value of type*result
, but indb.simpleQuery
it will be wrapped intoResult
and will pass!= nil
checkpg/base.go
Lines 544 to 553 in 51b8018
Note: Same issue exists in other parts of a code.
Possible Implementation
Workaround of this issue is to change a hook to look like this:
The text was updated successfully, but these errors were encountered: