Skip to content

Commit 93047ce

Browse files
authored
fix: non-nullable compatibility info (#15)
1 parent 138068a commit 93047ce

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

db/postgres/postgres_types.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
package postgres
22

33
import (
4-
"database/sql/driver"
5-
"encoding/json"
64
"time"
75

8-
"github.com/pkg/errors"
9-
106
"gorm.io/gorm"
117
)
128

@@ -65,7 +61,7 @@ type Mod struct {
6561
LastVersionDate *time.Time
6662
ModReference string
6763
Hidden bool
68-
Compatibility *CompatibilityInfo
64+
Compatibility *CompatibilityInfo `gorm:"serializer:json"`
6965

7066
Users []User `gorm:"many2many:user_mods;"`
7167

@@ -187,17 +183,6 @@ type CompatibilityInfo struct {
187183
EXP Compatibility `gorm:"type:compatibility"`
188184
}
189185

190-
func (c *CompatibilityInfo) Value() (driver.Value, error) {
191-
b, err := json.Marshal(c)
192-
return b, errors.Wrap(err, "failed to marshal")
193-
}
194-
195-
func (c *CompatibilityInfo) Scan(src any) error {
196-
v := src.([]byte)
197-
err := json.Unmarshal(v, c)
198-
return errors.Wrap(err, "failed to unmarshal")
199-
}
200-
201186
type Compatibility struct {
202187
State string
203188
Note string

0 commit comments

Comments
 (0)