mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(cloudcommon): panic when query an empty splitable model manager
fix panic when querying an empty splitable model manager, e.g. action-show
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user