mirror of
https://github.com/grafana/grafana.git
synced 2025-07-29 23:32:30 +08:00
SQL Expressions: Add CASE/WHEN nodes and fixes (and test) for functions just added to allowlist (#102040)
* SQL Expressions: Add CASE/WHEN SQL nodes to allowlist * Fixed and test for functions added in #102011 * Add remaining functions to the test-case These are mostly aliases, so the LLM chose to omit them originally. But adding now for completeness * Fix ordering of allowed nodes
This commit is contained in:
@ -63,6 +63,9 @@ func allowedNode(node sqlparser.SQLNode) (b bool) {
|
||||
case sqlparser.BoolVal:
|
||||
return
|
||||
|
||||
case *sqlparser.CaseExpr, *sqlparser.When:
|
||||
return
|
||||
|
||||
case sqlparser.ColIdent, *sqlparser.ColName, sqlparser.Columns:
|
||||
return
|
||||
|
||||
@ -75,7 +78,7 @@ func allowedNode(node sqlparser.SQLNode) (b bool) {
|
||||
case *sqlparser.ComparisonExpr:
|
||||
return
|
||||
|
||||
case *sqlparser.ConvertExpr:
|
||||
case *sqlparser.ConvertExpr, *sqlparser.ConvertType:
|
||||
return
|
||||
|
||||
case sqlparser.GroupBy:
|
||||
@ -84,6 +87,9 @@ func allowedNode(node sqlparser.SQLNode) (b bool) {
|
||||
case *sqlparser.IndexHints:
|
||||
return
|
||||
|
||||
case *sqlparser.IntervalExpr:
|
||||
return
|
||||
|
||||
case *sqlparser.Into:
|
||||
return
|
||||
|
||||
@ -120,6 +126,9 @@ func allowedNode(node sqlparser.SQLNode) (b bool) {
|
||||
case sqlparser.TableName, sqlparser.TableExprs, sqlparser.TableIdent:
|
||||
return
|
||||
|
||||
case *sqlparser.TrimExpr:
|
||||
return
|
||||
|
||||
case *sqlparser.With:
|
||||
return
|
||||
|
||||
@ -165,7 +174,7 @@ func allowedFunction(f *sqlparser.FuncExpr) (b bool) {
|
||||
return
|
||||
case "lower", "upper":
|
||||
return
|
||||
case "substring", "trim":
|
||||
case "substring":
|
||||
return
|
||||
|
||||
// Date functions
|
||||
@ -183,7 +192,7 @@ func allowedFunction(f *sqlparser.FuncExpr) (b bool) {
|
||||
return
|
||||
|
||||
// Type conversion
|
||||
case "cast", "convert":
|
||||
case "cast":
|
||||
return
|
||||
|
||||
default:
|
||||
|
Reference in New Issue
Block a user