Skip to content

Commit

Permalink
shovel: store empty bytea instead of NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
ryandotsmith committed Jun 18, 2024
1 parent 254206f commit 19de1ad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dig/dig.go
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,11 @@ func dbtype(abitype string, d []byte) any {
return false
case abitype == "string":
return string(d)
case abitype == "bytes":
if len(d) == 0 {
return []byte{}
}
return d
default:
return d
}
Expand Down
6 changes: 6 additions & 0 deletions dig/dig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,12 @@ func TestDBType(t *testing.T) {
&negInt{uint256.NewInt(0).Neg(uint256.NewInt(1))},
reflect.Ptr,
},
{
"bytes",
nil,
[]byte{},
reflect.Slice,
},
}
for _, tc := range cases {
got := dbtype(tc.abitype, tc.input)
Expand Down
1 change: 1 addition & 0 deletions indexsupply.com/shovel/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ The following resources are automatically deployed on a main commit:

On main but not yet associated with a new version tag.

- empty decoded bytes are stored as an empty byte array instead of NULL
- accept multiple URLs per source for redundancy
- fix db encoding for negative int{..256} values
- fix `error="getting receipts: no rpc error but empty result"`
Expand Down

0 comments on commit 19de1ad

Please sign in to comment.