Skip to content

Commit 7a4e784

Browse files
fix(scanners): 修复 SQL 注释清理导致的语句粘连问题
- 将 -- 注释替换为空格,而不是直接删除,以防止语句粘连
1 parent 1efd66a commit 7a4e784

File tree

1 file changed

+1
-1
lines changed
  • sqle/cmd/scannerd/scanners/common

1 file changed

+1
-1
lines changed

sqle/cmd/scannerd/scanners/common/parse.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func Parse(_ context.Context, sqlText string) ([]driverV2.Node, error) {
4646
func clearComments(sqlText string) string {
4747
// 将注释替换为一个空格,防止语句粘连
4848
sqlText = regexp.MustCompile(`(?s)/\*.*?\*/`).ReplaceAllString(sqlText, " ")
49-
sqlText = regexp.MustCompile(`--.*`).ReplaceAllString(sqlText, "")
49+
sqlText = regexp.MustCompile(`--.*`).ReplaceAllString(sqlText, " ")
5050
// 去除结尾分号后的内容
5151
idx := strings.Index(sqlText, ";")
5252
if idx >= 0 {

0 commit comments

Comments
 (0)