Fix custom DB type scan failing when nil.

This commit is contained in:
Kailash Nadh 2022-02-05 18:48:41 +05:30
parent 48ef3dcb14
commit 8fb459dc48

View file

@ -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)
}