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:
Sam Jewell
2025-03-12 15:57:50 +00:00
committed by GitHub
parent fe8e4563bd
commit 21b9d45ca6
2 changed files with 97 additions and 3 deletions

View File

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