Generate UUIDArray from template
- Fix error in Set - Specifically handle untyped nil
This commit is contained in:
@@ -15,6 +15,12 @@ type <%= pgtype_array_type %> struct {
|
||||
}
|
||||
|
||||
func (dst *<%= pgtype_array_type %>) Set(src interface{}) error {
|
||||
// untyped nil and typed nil interfaces are different
|
||||
if src == nil {
|
||||
*dst = <%= pgtype_array_type %>{Status: Null}
|
||||
return nil
|
||||
}
|
||||
|
||||
switch value := src.(type) {
|
||||
<% go_array_types.split(",").each do |t| %>
|
||||
case <%= t %>:
|
||||
@@ -40,7 +46,7 @@ func (dst *<%= pgtype_array_type %>) Set(src interface{}) error {
|
||||
if originalSrc, ok := underlyingSliceType(src); ok {
|
||||
return dst.Set(originalSrc)
|
||||
}
|
||||
return errors.Errorf("cannot convert %v to <%= pgtype_element_type %>", value)
|
||||
return errors.Errorf("cannot convert %v to <%= pgtype_array_type %>", value)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user