Skip to content

Commit a147b69

Browse files
authored
fix parsing of multiline strings (#516)
1 parent 688eef2 commit a147b69

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Diff for: pkg/sqlcmd/batch.go

+3
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,13 @@ parse:
104104
if ok {
105105
b.quote = 0
106106
}
107+
// don't bother looking for a command
108+
scannedCommand = true
107109
// inside a multiline comment
108110
case b.comment:
109111
i, ok = readMultilineComment(b.raw, i, b.rawlen)
110112
b.comment = !ok
113+
scannedCommand = true
111114
// start of a string
112115
case c == '\'' || c == '"' || c == '[':
113116
b.quote = c

Diff for: pkg/sqlcmd/batch_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ func TestBatchNext(t *testing.T) {
3838
{"select [bracket", []string{"select [bracket"}, nil, "["},
3939
{"select [bracket]]a]", []string{"select [bracket]]a]"}, nil, "-"},
4040
{"exit_1", []string{"exit_1"}, nil, "-"},
41+
{"print ('me\n!!me')", []string{"print ('me" + SqlcmdEol + "!!me')"}, nil, "-"},
42+
{"/*comment\n!!me*/", []string{"/*comment" + SqlcmdEol + "!!me*/"}, nil, "-"},
4143
}
4244
for _, test := range tests {
4345
b := NewBatch(sp(test.s, "\n"), newCommands())

0 commit comments

Comments
 (0)