diff --git a/pkg/sqlcmd/batch.go b/pkg/sqlcmd/batch.go index b13ff7df..4602cd9d 100644 --- a/pkg/sqlcmd/batch.go +++ b/pkg/sqlcmd/batch.go @@ -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 diff --git a/pkg/sqlcmd/batch_test.go b/pkg/sqlcmd/batch_test.go index 1c57ce80..e3175245 100644 --- a/pkg/sqlcmd/batch_test.go +++ b/pkg/sqlcmd/batch_test.go @@ -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())