Merge pull request #9919 from wy65701436/fix-9880

add empter result to list immutable rules
This commit is contained in:
Daniel Jiang 2019-11-19 00:01:41 -08:00 committed by GitHub
commit 70a2930330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -65,7 +65,7 @@ func (i *immutableRuleDao) GetImmutableRule(id int64) (*model.ImmutableRule, err
func (i *immutableRuleDao) QueryImmutableRuleByProjectID(projectID int64) ([]model.ImmutableRule, error) {
o := dao.GetOrmer()
qs := o.QueryTable(&model.ImmutableRule{}).Filter("ProjectID", projectID)
var r []model.ImmutableRule
r := make([]model.ImmutableRule, 0)
_, err := qs.All(&r)
if err != nil {
return nil, fmt.Errorf("failed to get immutable tag rule by projectID %d, error: %v", projectID, err)

View File

@ -79,7 +79,7 @@ func (drm *defaultRuleManager) QueryImmutableRuleByProjectID(projectID int64) ([
if err != nil {
return nil, err
}
var rules []model.Metadata
rules := make([]model.Metadata, 0)
for _, daoRule := range daoRules {
rule := model.Metadata{}
if err = json.Unmarshal([]byte(daoRule.TagFilter), &rule); err != nil {