fix(region): distinct fields (#20358)

This commit is contained in:
屈轩
2024-05-24 20:18:57 +08:00
committed by GitHub
parent fb39f7c3a1
commit ec11fc7b59
2 changed files with 4 additions and 3 deletions

View File

@@ -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)

View File

@@ -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