LooksLikeSQL performs basic heuristic checks to see if input looks like SQL.
(input string)
| 114 | |
| 115 | // LooksLikeSQL performs basic heuristic checks to see if input looks like SQL. |
| 116 | func LooksLikeSQL(input string) bool { |
| 117 | upper := strings.ToUpper(strings.TrimSpace(input)) |
| 118 | keywords := []string{ |
| 119 | "SELECT", "INSERT", "UPDATE", "DELETE", "CREATE", "DROP", "ALTER", |
| 120 | "TRUNCATE", "WITH", "MERGE", "EXPLAIN", "ANALYZE", "SHOW", "DESCRIBE", "DESC", |
| 121 | } |
| 122 | for _, kw := range keywords { |
| 123 | if strings.HasPrefix(upper, kw+" ") || strings.HasPrefix(upper, kw+"\n") || strings.HasPrefix(upper, kw+"\t") || upper == kw { |
| 124 | return true |
| 125 | } |
| 126 | } |
| 127 | return false |
| 128 | } |
| 129 | |
| 130 | // ExpandFileArgs expands file arguments, handling directories and wildcards. |
| 131 | func ExpandFileArgs(args []string) ([]string, error) { |
no outgoing calls