[#7538] set OnlyInt:true when a view column expression is loosely known to return int-only values

This commit is contained in:
Gani Georgiev
2026-02-22 11:06:08 +02:00
parent ab0edb80df
commit eb28f898d0
3 changed files with 80 additions and 3 deletions

View File

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