Fix custom DB type scan failing when nil.
This commit is contained in:
parent
48ef3dcb14
commit
8fb459dc48
1 changed files with 10 additions and 0 deletions
|
@ -325,6 +325,11 @@ func (s SubscriberAttribs) Value() (driver.Value, error) {
|
|||
|
||||
// Scan unmarshals JSONB from the DB.
|
||||
func (s SubscriberAttribs) Scan(src interface{}) error {
|
||||
if src == nil {
|
||||
s = make(SubscriberAttribs)
|
||||
return nil
|
||||
}
|
||||
|
||||
if data, ok := src.([]byte); ok {
|
||||
return json.Unmarshal(data, &s)
|
||||
}
|
||||
|
@ -333,6 +338,11 @@ func (s SubscriberAttribs) Scan(src interface{}) error {
|
|||
|
||||
// Scan unmarshals JSONB from the DB.
|
||||
func (s StringIntMap) Scan(src interface{}) error {
|
||||
if src == nil {
|
||||
s = make(StringIntMap)
|
||||
return nil
|
||||
}
|
||||
|
||||
if data, ok := src.([]byte); ok {
|
||||
return json.Unmarshal(data, &s)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue