[#7538] set OnlyInt:true when a view column expression is loosely known to return int-only values
This commit is contained in:
23
core/view.go
23
core/view.go
@@ -257,7 +257,16 @@ func parseQueryToFields(app App, selectQuery string) (map[string]*queryField, er
|
||||
}
|
||||
|
||||
// numeric aggregations
|
||||
if strings.HasPrefix(colLower, "count(") || strings.HasPrefix(colLower, "total(") {
|
||||
if strings.HasPrefix(colLower, "count(") {
|
||||
result[col.alias] = &queryField{
|
||||
field: &NumberField{
|
||||
Name: col.alias,
|
||||
OnlyInt: true,
|
||||
},
|
||||
}
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(colLower, "total(") {
|
||||
result[col.alias] = &queryField{
|
||||
field: &NumberField{
|
||||
Name: col.alias,
|
||||
@@ -268,16 +277,24 @@ func parseQueryToFields(app App, selectQuery string) (map[string]*queryField, er
|
||||
|
||||
castMatch := castRegex.FindStringSubmatch(colLower)
|
||||
|
||||
// numeric casts
|
||||
// casts
|
||||
if len(castMatch) == 2 {
|
||||
switch castMatch[1] {
|
||||
case "real", "integer", "int", "decimal", "numeric":
|
||||
case "real", "decimal", "numeric":
|
||||
result[col.alias] = &queryField{
|
||||
field: &NumberField{
|
||||
Name: col.alias,
|
||||
},
|
||||
}
|
||||
continue
|
||||
case "int", "integer":
|
||||
result[col.alias] = &queryField{
|
||||
field: &NumberField{
|
||||
Name: col.alias,
|
||||
OnlyInt: true,
|
||||
},
|
||||
}
|
||||
continue
|
||||
case "text":
|
||||
result[col.alias] = &queryField{
|
||||
field: &TextField{
|
||||
|
||||
Reference in New Issue
Block a user