Skip to content

Commit

Permalink
fix parsing of multiline strings (#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
shueybubbles authored May 3, 2024
1 parent 688eef2 commit a147b69
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/sqlcmd/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,13 @@ parse:
if ok {
b.quote = 0
}
// don't bother looking for a command
scannedCommand = true
// inside a multiline comment
case b.comment:
i, ok = readMultilineComment(b.raw, i, b.rawlen)
b.comment = !ok
scannedCommand = true
// start of a string
case c == '\'' || c == '"' || c == '[':
b.quote = c
Expand Down
2 changes: 2 additions & 0 deletions pkg/sqlcmd/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func TestBatchNext(t *testing.T) {
{"select [bracket", []string{"select [bracket"}, nil, "["},
{"select [bracket]]a]", []string{"select [bracket]]a]"}, nil, "-"},
{"exit_1", []string{"exit_1"}, nil, "-"},
{"print ('me\n!!me')", []string{"print ('me" + SqlcmdEol + "!!me')"}, nil, "-"},
{"/*comment\n!!me*/", []string{"/*comment" + SqlcmdEol + "!!me*/"}, nil, "-"},
}
for _, test := range tests {
b := NewBatch(sp(test.s, "\n"), newCommands())
Expand Down

0 comments on commit a147b69

Please sign in to comment.