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

5
sql.go
View File

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