diff --git a/pkg/cloudcommon/db/virtualresource.go b/pkg/cloudcommon/db/virtualresource.go index 94178ad82ea..46646ff9218 100644 --- a/pkg/cloudcommon/db/virtualresource.go +++ b/pkg/cloudcommon/db/virtualresource.go @@ -16,6 +16,7 @@ package db import ( "context" + "database/sql" "yunion.io/x/jsonutils" "yunion.io/x/log" @@ -118,10 +119,9 @@ func (manager *SVirtualResourceBaseManager) CustomizedTotalCount(ctx context.Con StatusInfo []apis.StatusStatisticStatusInfo }{} - var err error - results.Count, err = totalQ.CountWithError() - if err != nil { - return -1, nil, errors.Wrapf(err, "CountWithError") + err := totalQ.First(&results.TotalCountBase) + if err != nil && errors.Cause(err) != sql.ErrNoRows { + return -1, nil, errors.Wrapf(err, "First") } totalSQ := totalQ.ResetFields().SubQuery()