MCPcopy Create free account
hub / github.com/bytebase/bytebase / isEmptySQL

Function isEmptySQL

backend/plugin/parser/standard/split.go:51–77  ·  view source on GitHub ↗

isEmptySQL checks if the SQL contains only whitespace and comments.

(sql string)

Source from the content-addressed store, hash-verified

49
50// isEmptySQL checks if the SQL contains only whitespace and comments.
51func isEmptySQL(sql string) bool {
52 trimmed := strings.TrimSpace(sql)
53 if trimmed == "" {
54 return true
55 }
56 // Check if it's only comments
57 if strings.HasPrefix(trimmed, "--") || strings.HasPrefix(trimmed, "/*") {
58 // Simple heuristic: if after removing comment markers there's no SQL
59 lines := strings.Split(trimmed, "\n")
60 for _, line := range lines {
61 line = strings.TrimSpace(line)
62 if line == "" {
63 continue
64 }
65 if strings.HasPrefix(line, "--") {
66 continue
67 }
68 if strings.HasPrefix(line, "/*") && strings.HasSuffix(line, "*/") {
69 continue
70 }
71 // Found non-comment content
72 return false
73 }
74 return true
75 }
76 return false
77}
78
79// applyMultiStatements splits the statement by semicolons and invokes f for
80// each sub-statement with the text slice from the original statement and its

Callers 1

SplitSQLFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected