Skip to content

Commit 101ec52

Browse files
stores: fix settings and pricetable scan
1 parent 125d8c7 commit 101ec52

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

renterd

-29.3 MB
Binary file not shown.

stores/sql/types.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,13 @@ func (h Hash256) Value() (driver.Value, error) {
195195

196196
// Scan scan value into HostSettings, implements sql.Scanner interface.
197197
func (hs *HostSettings) Scan(value interface{}) error {
198-
bytes, ok := value.([]byte)
199-
if !ok {
198+
var bytes []byte
199+
switch value := value.(type) {
200+
case string:
201+
bytes = []byte(value)
202+
case []byte:
203+
bytes = value
204+
default:
200205
return errors.New(fmt.Sprint("failed to unmarshal Settings value:", value))
201206
}
202207
return json.Unmarshal(bytes, hs)
@@ -212,8 +217,13 @@ func (hs HostSettings) Value() (driver.Value, error) {
212217

213218
// Scan scan value into PriceTable, implements sql.Scanner interface.
214219
func (pt *PriceTable) Scan(value interface{}) error {
215-
bytes, ok := value.([]byte)
216-
if !ok {
220+
var bytes []byte
221+
switch value := value.(type) {
222+
case string:
223+
bytes = []byte(value)
224+
case []byte:
225+
bytes = value
226+
default:
217227
return errors.New(fmt.Sprint("failed to unmarshal PriceTable value:", value))
218228
}
219229
return json.Unmarshal(bytes, pt)

0 commit comments

Comments
 (0)