diff --git a/byte.go b/byte.go index 69339ff..edc8613 100644 --- a/byte.go +++ b/byte.go @@ -5,8 +5,6 @@ import ( "database/sql/driver" "encoding/json" "errors" - - "gopkg.in/nullbio/null.v6/convert" ) // Byte is an nullable int. @@ -115,8 +113,17 @@ func (b *Byte) Scan(value interface{}) error { b.Byte, b.Valid = 0, false return nil } + + val := value.(string) + if len(val) == 0 { + b.Valid = false + b.Byte = 0 + return nil + } + b.Valid = true - return convert.ConvertAssign(&b.Byte, value) + b.Byte = byte(val[0]) + return nil } // Value implements the driver Valuer interface. diff --git a/byte_test.go b/byte_test.go index a6076f4..19e547e 100644 --- a/byte_test.go +++ b/byte_test.go @@ -136,7 +136,7 @@ func TestByteSetValid(t *testing.T) { func TestByteScan(t *testing.T) { var i Byte - err := i.Scan('b') + err := i.Scan("b") maybePanic(err) assertByte(t, i, "scanned int")