forked from mirror/enumer
handle database NULL values
This commit is contained in:
parent
0978fe0e3d
commit
3e78fe69e0
4
sql.go
4
sql.go
|
@ -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")
|
||||||
|
|
Loading…
Reference in New Issue