Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

Fix custom DB type scan failing when nil.

Kailash Nadh8fb459dc48da
diff --git a/models/models.go b/models/models.go
index 402c672c..9388c08c 100644
--- a/models/models.go
+++ b/models/models.go
@@ -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)
}