Merge pull request #9527 from swordqiu/hotfix/qj-split-table-empty-panic

fix(cloudcommon): panic when query an empty splitable model manager
This commit is contained in:
Zexi Li
2020-12-20 02:07:45 +08:00
committed by GitHub
5 changed files with 16 additions and 5 deletions
+6 -1
View File
@@ -611,7 +611,12 @@ func ListItems(manager IModelManager, ctx context.Context, userCred mcclient.Tok
}
union, err := sqlchemy.UnionWithError(subqs...)
if err != nil {
return nil, errors.Wrap(err, "sqlchemy.UnionWithError")
if errors.Cause(err) == sql.ErrNoRows {
emptyList := modulebase.ListResult{Data: []jsonutils.JSONObject{}}
return &emptyList, nil
} else {
return nil, errors.Wrap(err, "sqlchemy.UnionWithError")
}
}
q = union.Query()
} else {