diff --git a/pkg/cloudcommon/db/modelbase.go b/pkg/cloudcommon/db/modelbase.go index 5895230ff00..7215f7d9cb4 100644 --- a/pkg/cloudcommon/db/modelbase.go +++ b/pkg/cloudcommon/db/modelbase.go @@ -513,7 +513,7 @@ func (manager *SModelBaseManager) GetPropertyDistinctFields(ctx context.Context, result := jsonutils.NewDict() fields := jsonutils.NewArray() if len(input.Field) > 0 { - sq := q.Copy() + sq := q.Copy().ResetFields() // query field for i := 0; i < len(input.Field); i++ { sq = sq.AppendField(sq.Field(input.Field[i])) @@ -536,7 +536,7 @@ func (manager *SModelBaseManager) GetPropertyDistinctFields(ctx context.Context, extraFields := jsonutils.NewArray() if len(input.ExtraResource) > 0 && len(input.ExtraField) > 0 { // query extra field - sq := q.Copy() + sq := q.Copy().ResetFields() em := GetModelManager(input.ExtraResource) if gotypes.IsNil(em) { return nil, httperrors.NewInputParameterError("invalid extra_resource %s", input.ExtraResource) diff --git a/vendor/yunion.io/x/sqlchemy/query.go b/vendor/yunion.io/x/sqlchemy/query.go index e30b46b2764..ba72e8214c2 100644 --- a/vendor/yunion.io/x/sqlchemy/query.go +++ b/vendor/yunion.io/x/sqlchemy/query.go @@ -50,7 +50,8 @@ type sQueryJoin struct { } // SQuery is a data structure represents a SQL query in the form of -// SELECT ... FROM ... JOIN ... ON ... WHERE ... GROUP BY ... ORDER BY ... HAVING ... +// +// SELECT ... FROM ... JOIN ... ON ... WHERE ... GROUP BY ... ORDER BY ... HAVING ... type SQuery struct { rawSql string fields []IQueryField