Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions batch/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ func stateSep(l *lexer) stateFn {
return nil
}
s := l.Sql[l.At+len(l.Sep):]
if unicode.IsLetter(rune(s[0])) {
// If the first character after the separator is a letter, then
// it's a text line that happens to start with the separator.
// E.g. statement "goto", column name "gone", etc.
// We don't want to split here.
return stateText
}

parseNumberStart := -1
loop:
Expand Down
24 changes: 24 additions & 0 deletions batch/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,29 @@ select top 1 1`,
select top 1 1`,
},
},
testItem{
Sql: `
create table t (
id int,
gone_ts datetime
)
go
select
gone_ts
from test_table
go`,
Expect: []string{`
create table t (
id int,
gone_ts datetime
)
`, `
select
gone_ts
from test_table
`,
},
},
testItem{Sql: `"0'"`, Expect: []string{`"0'"`}},
testItem{Sql: "0'", Expect: []string{"0'"}},
testItem{Sql: "--", Expect: []string{"--"}},
Expand All @@ -78,6 +101,7 @@ select top 1 1`,
testItem{Sql: "select 'hi\\\r\n-hello';", Expect: []string{"select 'hi-hello';"}},
testItem{Sql: "select 'hi\\\r-hello';", Expect: []string{"select 'hi-hello';"}},
testItem{Sql: "select 'hi\\\n\nhello';", Expect: []string{"select 'hi\nhello';"}},
testItem{Sql: "select\ngone_ts\nfrom t;", Expect: []string{"select\ngone_ts\nfrom t;"}},
}

index := -1
Expand Down