From b873aa2b431b3ff78acd919b777b0cfe49664ce6 Mon Sep 17 00:00:00 2001 From: Florent AIDE Date: Fri, 11 Dec 2015 06:37:27 +0100 Subject: [PATCH] Return nil instead of empty err in Scan --- decimal.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/decimal.go b/decimal.go index fd2f4c5..cbbce7b 100644 --- a/decimal.go +++ b/decimal.go @@ -469,20 +469,19 @@ func (d Decimal) MarshalJSON() ([]byte, error) { // Scan implements the sql.Scanner interface for database deserialization. func (d *Decimal) Scan(value interface{}) error { - var err error // first try to see if the data is stored in database as a Numeric datatype switch v := value.(type) { case float64: // numeric in sqlite3 sends us float64 *d = NewFromFloat(v) - return err + return nil case int64: // at least in sqlite3 when the value is 0 in db, the data is sent // to us as an int64 instead of a float64 ... *d = New(v, 0) - return err + return nil default: // default is trying to interpret value stored as string