MCPcopy Create free account
hub / github.com/PostHog/duckgres / stripLeadingSQL

Function stripLeadingSQL

transpiler/show_create.go:172–191  ·  view source on GitHub ↗

stripLeadingSQL strips leading whitespace, line comments (--), and block comments (/* ... */) from SQL. Mirrors the logic in hasAnyPrefix.

(s string)

Source from the content-addressed store, hash-verified

170// stripLeadingSQL strips leading whitespace, line comments (--), and block
171// comments (/* ... */) from SQL. Mirrors the logic in hasAnyPrefix.
172func 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.
194func findAllUnquotedDots(s string) []int {

Callers 2

interceptShowCreateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected