bug fix if string instead of []byte is returned from db (this is the

case for postgreSQL)
This commit is contained in:
marco 2016-10-21 15:20:44 +02:00
parent af92007434
commit af72d0db85
1 changed files with 7 additions and 4 deletions

11
sql.go
View File

@ -12,12 +12,15 @@ const scanMethod = `func (i *%[1]s) Scan(value interface{}) error {
return nil
}
bytes, ok := value.([]byte)
str, ok := value.(string)
if !ok {
return fmt.Errorf("value is not a byte slice")
}
bytes, ok := value.([]byte)
if !ok {
return fmt.Errorf("value is not a byte slice")
}
str := string(bytes[:])
str = string(bytes[:])
}
val, err := %[1]sString(str)
if err != nil {