handle database NULL values

This commit is contained in:
marco 2016-02-11 19:27:29 +01:00
parent 0978fe0e3d
commit 3e78fe69e0
1 changed files with 4 additions and 0 deletions

4
sql.go
View File

@ -8,6 +8,10 @@ const valueMethod = `func (i %[1]s) Value() (driver.Value, error) {
` `
const scanMethod = `func (i *%[1]s) Scan(value interface{}) error { const scanMethod = `func (i *%[1]s) Scan(value interface{}) error {
if value == nil {
return nil
}
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")