fix: gen enum sql.Value issue

This commit is contained in:
Rogee
2025-01-10 09:57:56 +08:00
parent bd6d6bc6e8
commit fa480d33c3
5 changed files with 71 additions and 2 deletions

View File

@@ -189,14 +189,18 @@ func (x *{{.enum.Name}}) Scan(value interface{}) (err error) {
}
}{{end}}
}
return
return
}
{{ if or .sql .sqlnullstr }}
// Value implements the driver Valuer interface.
func (x {{.enum.Name}}) Value() (driver.Value, error) {
{{- if eq .enum.Type "int" "int8" "int16" "int32" "int64" "uint" "uint8" "uint16" "uint32" "uint64" }}
return int64(x), nil
{{- else }}
return {{.enum.Type }}(x), nil
{{- end }}
}
{{ else }}
// Value implements the driver Valuer interface.