From 8cf1bb2d0d7f509d9f17bfba0e2fa522437cb185 Mon Sep 17 00:00:00 2001 From: heppu Date: Thu, 1 May 2025 20:24:55 +0300 Subject: [PATCH 1/2] Add test for batch.Split bug --- batch/batch_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/batch/batch_test.go b/batch/batch_test.go index 51978283..00921770 100644 --- a/batch/batch_test.go +++ b/batch/batch_test.go @@ -67,6 +67,15 @@ select top 1 1`, select top 1 1`, }, }, + testItem{ + Sql: `PRINT 1 +GOTO Bookmark +GO +PRINT 2 +Bookmark: +GO`, + Expect: []string{"PRINT 1\nGOTO Bookmark\n", "\nPRINT 2\nBookmark:\n"}, + }, testItem{Sql: `"0'"`, Expect: []string{`"0'"`}}, testItem{Sql: "0'", Expect: []string{"0'"}}, testItem{Sql: "--", Expect: []string{"--"}}, From 760489e7f2c2c0953f638755acc6f3556ed91631 Mon Sep 17 00:00:00 2001 From: heppu Date: Thu, 1 May 2025 23:19:29 +0300 Subject: [PATCH 2/2] Fix GOTO batch parsing bug --- batch/batch.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/batch/batch.go b/batch/batch.go index 5b793dcb..01e99f3d 100644 --- a/batch/batch.go +++ b/batch/batch.go @@ -46,6 +46,12 @@ func hasPrefixFold(s, sep string) bool { if len(s) < len(sep) { return false } + + // Forward lookup to see if the word continues. + if len(s) > len(sep) && unicode.IsLetter(rune(s[len(sep)])) { + return false + } + return strings.EqualFold(s[:len(sep)], sep) }