Skip to content

Commit

Permalink
fix panic with auto test, project "existedRule" can't be used if not …
Browse files Browse the repository at this point in the history
…exist
  • Loading branch information
sjjian committed Dec 3, 2021
1 parent 0de6d6e commit fe45fe4
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions sqle/model/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,21 @@ func (s *Storage) CreateRulesIfNotExist(rules map[string][]*driver.Rule) error {
}
// rule will be created or update if:
// 1. rule not exist;
// 2. rule no params in db, and has params in code.
existedRuleHasParams := existedRule.Params != nil && len(existedRule.Params.Params) > 0
ruleHasParams := len(rule.Params) > 0
if !exist || (!existedRuleHasParams && ruleHasParams) {
err = s.Save(GenerateRuleByDriverRule(rule, dbType))
if !exist {
err := s.Save(GenerateRuleByDriverRule(rule, dbType))
if err != nil {
return err
}
} else {
// 2. rule no params in db, and has params in code.
existedRuleHasParams := existedRule.Params != nil && len(existedRule.Params.Params) > 0
ruleHasParams := len(rule.Params) > 0
if !exist || (!existedRuleHasParams && ruleHasParams) {
err := s.Save(GenerateRuleByDriverRule(rule, dbType))
if err != nil {
return err
}
}
}
}
}
Expand Down

0 comments on commit fe45fe4

Please sign in to comment.