Skip to content

Commit c1fe20e

Browse files
authored
Fix unmarshaling fixed value over existing decimal (#10)
1 parent 3145a27 commit c1fe20e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

decimal.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,13 +774,15 @@ func (d *Decimal) Scan(value interface{}) error {
774774
fixed, ok := parseFixed(v)
775775
if ok {
776776
d.fixed = fixed
777+
d.fallback = nil
777778
return nil
778779
}
779780

780781
case string:
781782
fixed, ok := parseFixed(v)
782783
if ok {
783784
d.fixed = fixed
785+
d.fallback = nil
784786
return nil
785787
}
786788
}
@@ -959,6 +961,7 @@ func (d *Decimal) UnmarshalBinary(data []byte) error {
959961
func (d *Decimal) UnmarshalJSON(decimalBytes []byte) error {
960962
if fixed, ok := parseFixed(decimalBytes); ok {
961963
d.fixed = fixed
964+
d.fallback = nil
962965
return nil
963966
}
964967

@@ -976,6 +979,7 @@ func (d *Decimal) UnmarshalJSON(decimalBytes []byte) error {
976979
func (d *Decimal) UnmarshalText(text []byte) error {
977980
if fixed, ok := parseFixed(text); ok {
978981
d.fixed = fixed
982+
d.fallback = nil
979983
return nil
980984
}
981985

0 commit comments

Comments
 (0)