diff --git a/weed/util/sqlutil/splitter.go b/weed/util/sqlutil/splitter.go index 098a7ecb3..a9d6befa9 100644 --- a/weed/util/sqlutil/splitter.go +++ b/weed/util/sqlutil/splitter.go @@ -133,10 +133,8 @@ func SplitStatements(query string) []string { } } - // If no statements found, return the original query as a single statement if len(statements) == 0 { - return []string{strings.TrimSpace(strings.TrimSuffix(strings.TrimSpace(query), ";"))} + return []string{} } - return statements } diff --git a/weed/util/sqlutil/splitter_test.go b/weed/util/sqlutil/splitter_test.go index 91fac6196..13f3baf2b 100644 --- a/weed/util/sqlutil/splitter_test.go +++ b/weed/util/sqlutil/splitter_test.go @@ -96,6 +96,16 @@ func TestSplitStatements(t *testing.T) { input: " \n\t ", expected: []string{}, }, + { + name: "Only single line comment", + input: "-- just a comment", + expected: []string{}, + }, + { + name: "Only multi-line comment", + input: "/* just a comment; with separator */", + expected: []string{}, + }, } for _, tt := range tests {