Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -1864,6 +1864,10 @@ func (d *Decimal) Scan(value interface{}) error {
*d, err = NewFromString(unquoteIfQuoted(string(v)))
return err

case big.Int:
*d = NewFromBigInt(&v, 0)
return nil

default:
return fmt.Errorf("could not convert value '%+v' to any known type", value)
}
Expand Down
5 changes: 5 additions & 0 deletions decimal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2479,6 +2479,11 @@ func TestDecimal_Scan(t *testing.T) {
scanHelper(t, dbvalueStr, expected)
scanHelper(t, valueStr, expected)

// test big.Int
value := big.NewInt(dbvalueInt)
expected = NewFromBigInt(value, 0)
scanHelper(t, *value, expected)

type foo struct{}
a := Decimal{}
err = a.Scan(foo{})
Expand Down