Skip to content

Commit

Permalink
Added mysql clause in settings register to avoid printing errors when…
Browse files Browse the repository at this point in the history
… trying to create exsisting settings
  • Loading branch information
Davide bonomini committed Jan 25, 2024
1 parent b14de46 commit 57e09c2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/settings/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (config *Database) Register(sets ...any) error {
grandfatherDomainId = 0
break
}
err = db.Where("domain = ? AND parent_domain = ?", parentDomain.Domain, grandfatherDomainId).Save(&parentDomain).Error
err = db.Clauses(clause.Insert{Modifier: "IGNORE"}).Where("domain = ? AND parent_domain = ?", parentDomain.Domain, grandfatherDomainId).Save(&parentDomain).Error
if err != nil {
return err
}
Expand Down Expand Up @@ -260,7 +260,7 @@ func (config *Database) Register(sets ...any) error {
}

// Now we can finally create the setting parameter, subdomain and domain in one go
err = db.Where("parent_domain = 0 AND domain = ?", parentDomain.Domain).Save(&parentDomain).Error
err = db.Clauses(clause.Insert{Modifier: "IGNORE"}).Where("parent_domain = 0 AND domain = ?", parentDomain.Domain).Save(&parentDomain).Error
if err != nil {
return err
}
Expand Down

0 comments on commit 57e09c2

Please sign in to comment.