MCPcopy
hub / github.com/sqldef/sqldef / stripOuterSQLParens

Function stripOuterSQLParens

database/mssql/parser.go:288–298  ·  view source on GitHub ↗
(expr string)

Source from the content-addressed store, hash-verified

286}
287
288func stripOuterSQLParens(expr string) string {
289 trimmed := strings.TrimSpace(expr)
290 for len(trimmed) > 0 && trimmed[0] == '(' {
291 _, end, ok := scanBalancedParenthesizedSQL(trimmed, 0)
292 if !ok || end != len(trimmed) {
293 break
294 }
295 trimmed = strings.TrimSpace(trimmed[1 : len(trimmed)-1])
296 }
297 return trimmed
298}
299
300func scanBalancedParenthesizedSQL(sql string, start int) (string, int, bool) {
301 if start >= len(sql) || sql[start] != '(' {

Callers 1

Calls 1

Tested by

no test coverage detected