Browse Source

null string

ls 5 years ago
parent
commit
616fcb21c3
1 changed files with 9 additions and 3 deletions
  1. 9 3
      types/string.go

+ 9 - 3
types/string.go

@@ -22,11 +22,17 @@ func (s TextNull) Value() (driver.Value, error) {
 // Scan implements the sql.Scanner interface,
 // and turns the bytes incoming from MySQL into a string
 func (s *TextNull) Scan(src interface{}) error {
-	if src == nil {
-		*s = TextNull("")
+	if src != nil {
+		v, ok := src.([]byte)
+		if !ok {
+			return errors.New("bad []byte type assertion")
+		}
+
+		*s = TextNull(v)
+		return nil
 	}
 
-	convertAssign(&s, src)
+	*s = TextNull("")
 
 	return nil
 }