提交 e08a3b05 编写于 作者: martianzhang's avatar martianzhang

refix #116

  single line comment in sql will merge next line into before one.
上级 de99de7e
...@@ -31,7 +31,10 @@ where col = 1 ...@@ -31,7 +31,10 @@ where col = 1
-- --
from tb from tb
where col = 1 where col = 1
17 17 select * from
-- comment
tb;
18
-- comment -- comment
0 select * from test\Ghello 0 select * from test\Ghello
1 select 'hello\Gworld', col from test\Ghello 1 select 'hello\Gworld', col from test\Ghello
......
...@@ -928,6 +928,7 @@ func SplitStatement(buf []byte, delimiter []byte) (string, string, []byte) { ...@@ -928,6 +928,7 @@ func SplitStatement(buf []byte, delimiter []byte) (string, string, []byte) {
if b == '\r' || b == '\n' { if b == '\r' || b == '\n' {
if singleLineComment { if singleLineComment {
sql = string(buf[:i]) sql = string(buf[:i])
singleLineComment = false
if strings.HasPrefix(strings.TrimSpace(sql), "--") || if strings.HasPrefix(strings.TrimSpace(sql), "--") ||
strings.HasPrefix(strings.TrimSpace(sql), "#") { strings.HasPrefix(strings.TrimSpace(sql), "#") {
// just comment, query start with '--', '#' // just comment, query start with '--', '#'
......
...@@ -146,6 +146,10 @@ where col = 1`), ...@@ -146,6 +146,10 @@ where col = 1`),
-- --
from tb from tb
where col = 1`), where col = 1`),
[]byte(`select * from
-- comment
tb;
select col from tb where col = 1;`),
// https://github.com/XiaoMi/soar/issues/120 // https://github.com/XiaoMi/soar/issues/120
[]byte(` []byte(`
-- comment -- comment
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册