stripLeadingSQL strips leading whitespace, line comments (--), and block comments (/* ... */) from SQL. Mirrors the logic in hasAnyPrefix.
(s string)
| 170 | // stripLeadingSQL strips leading whitespace, line comments (--), and block |
| 171 | // comments (/* ... */) from SQL. Mirrors the logic in hasAnyPrefix. |
| 172 | func stripLeadingSQL(s string) string { |
| 173 | s = strings.TrimLeft(s, " \t\n\r") |
| 174 | for { |
| 175 | if strings.HasPrefix(s, "--") { |
| 176 | nl := strings.IndexByte(s, '\n') |
| 177 | if nl < 0 { |
| 178 | return "" |
| 179 | } |
| 180 | s = strings.TrimLeft(s[nl+1:], " \t\n\r") |
| 181 | } else if strings.HasPrefix(s, "/*") { |
| 182 | end := strings.Index(s, "*/") |
| 183 | if end < 0 { |
| 184 | return "" |
| 185 | } |
| 186 | s = strings.TrimLeft(s[end+2:], " \t\n\r") |
| 187 | } else { |
| 188 | return s |
| 189 | } |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | // findAllUnquotedDots returns indices of all dots outside double-quoted identifiers. |
| 194 | func findAllUnquotedDots(s string) []int { |
no outgoing calls
no test coverage detected