作者 yangfu

fix: table preview

@@ -221,3 +221,20 @@ func SelectsExprToMapById(items []SelectExpr) map[string]SelectExpr { @@ -221,3 +221,20 @@ func SelectsExprToMapById(items []SelectExpr) map[string]SelectExpr {
221 } 221 }
222 return res 222 return res
223 } 223 }
  224 +
  225 +type QueryComponents []*QueryComponent
  226 +
  227 +func (list QueryComponents) IsEmpty(t TableType) bool {
  228 + if len(list) == 0 {
  229 + return true
  230 + }
  231 + for _, q := range list {
  232 + switch t {
  233 + case CalculateTable:
  234 + if q.Aggregation != nil && len(q.Aggregation.RowFields) == 0 && len(q.Aggregation.ValueFields) == 0 {
  235 + return true
  236 + }
  237 + }
  238 + }
  239 + return false
  240 +}
@@ -278,7 +278,7 @@ func (ptr *QuerySetService) PreviewPrepare(ctx *domain.Context, querySetId int, @@ -278,7 +278,7 @@ func (ptr *QuerySetService) PreviewPrepare(ctx *domain.Context, querySetId int,
278 return t, nil 278 return t, nil
279 } 279 }
280 } 280 }
281 - if len(queryComponents) == 0 { 281 + if domain.QueryComponents(queryComponents).IsEmpty(domain.TableType(querySet.Type)) {
282 return &domain.Table{}, nil 282 return &domain.Table{}, nil
283 } 283 }
284 284