作者 yangfu

fix: table preview

... ... @@ -26,7 +26,6 @@ require (
github.com/sergi/go-diff v1.2.0 // indirect
github.com/shopspring/decimal v1.3.1
github.com/smartystreets/goconvey v1.7.2 // indirect
github.com/sony/sonyflake v1.1.0 // indirect
github.com/stretchr/testify v1.7.1
github.com/valyala/fasthttp v1.38.0 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
... ...
... ... @@ -162,12 +162,7 @@ func NewFormulaCalculate(table *domain.Table, queryComponent *domain.QueryCompon
}
if queryComponent.Aggregation != nil {
res.DatabaseTableName = queryComponent.MasterTable.SQLName
for i, f := range queryComponent.Aggregation.ValueFields {
tableField, ok := table.MatchField(&domain.Field{Name: f.DisplayName})
if !ok {
continue
}
if i == 0 {
if len(queryComponent.Aggregation.ValueFields)>0 || len(queryComponent.Aggregation.RowFields)>0{
res.FormulaCalculateFields = append(res.FormulaCalculateFields, &FormulaCalculateField{
DatabaseTableName: queryComponent.MasterTable.SQLName,
FieldSchema: NewFieldSchemaFromField(&domain.Field{
... ... @@ -179,6 +174,11 @@ func NewFormulaCalculate(table *domain.Table, queryComponent *domain.QueryCompon
CalculateFieldName: "id",
})
}
for _, f := range queryComponent.Aggregation.ValueFields {
tableField, ok := table.MatchField(&domain.Field{Name: f.DisplayName})
if !ok {
continue
}
res.FormulaCalculateFields = append(res.FormulaCalculateFields, &FormulaCalculateField{
DatabaseTableName: queryComponent.MasterTable.SQLName,
FieldSchema: NewFieldSchemaFromField(f.Field),
... ...