Skip to content

Commit

Permalink
Fix unmarshaling fixed value over existing decimal
Browse files Browse the repository at this point in the history
  • Loading branch information
Neal committed Aug 22, 2023
1 parent 3145a27 commit 3ba6eae
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,13 +774,15 @@ func (d *Decimal) Scan(value interface{}) error {
fixed, ok := parseFixed(v)
if ok {
d.fixed = fixed
d.fallback = nil
return nil
}

case string:
fixed, ok := parseFixed(v)
if ok {
d.fixed = fixed
d.fallback = nil
return nil
}
}
Expand Down Expand Up @@ -959,6 +961,7 @@ func (d *Decimal) UnmarshalBinary(data []byte) error {
func (d *Decimal) UnmarshalJSON(decimalBytes []byte) error {
if fixed, ok := parseFixed(decimalBytes); ok {
d.fixed = fixed
d.fallback = nil
return nil
}

Expand All @@ -976,6 +979,7 @@ func (d *Decimal) UnmarshalJSON(decimalBytes []byte) error {
func (d *Decimal) UnmarshalText(text []byte) error {
if fixed, ok := parseFixed(text); ok {
d.fixed = fixed
d.fallback = nil
return nil
}

Expand Down

0 comments on commit 3ba6eae

Please sign in to comment.