Parcourir la source

feat(channel): add error handling for SaveWithoutKey when channel ID is 0

CaIon il y a 2 mois
Parent
commit
d9634ad2d3
1 fichiers modifiés avec 3 ajouts et 0 suppressions
  1. 3 0
      model/channel.go

+ 3 - 0
model/channel.go

@@ -254,6 +254,9 @@ func (channel *Channel) Save() error {
 }
 
 func (channel *Channel) SaveWithoutKey() error {
+	if channel.Id == 0 {
+		return errors.New("channel ID is 0")
+	}
 	return DB.Omit("key").Save(channel).Error
 }