作者 yangfu

fix: table preview

... ... @@ -221,3 +221,20 @@ func SelectsExprToMapById(items []SelectExpr) map[string]SelectExpr {
}
return res
}
type QueryComponents []*QueryComponent
func (list QueryComponents) IsEmpty(t TableType) bool {
if len(list) == 0 {
return true
}
for _, q := range list {
switch t {
case CalculateTable:
if q.Aggregation != nil && len(q.Aggregation.RowFields) == 0 && len(q.Aggregation.ValueFields) == 0 {
return true
}
}
}
return false
}
... ...
... ... @@ -278,7 +278,7 @@ func (ptr *QuerySetService) PreviewPrepare(ctx *domain.Context, querySetId int,
return t, nil
}
}
if len(queryComponents) == 0 {
if domain.QueryComponents(queryComponents).IsEmpty(domain.TableType(querySet.Type)) {
return &domain.Table{}, nil
}
... ...