Skip to content

Commit 0b4f30d

Browse files
Merge pull request #5 from stackql/feature/change-delimiter
replace-backtick-with-double-quote
2 parents 9895e99 + c5c9690 commit 0b4f30d

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

go/vt/sqlparser/token.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ import (
2828
)
2929

3030
const (
31-
defaultBufSize = 4096
32-
eofChar = 0x100
31+
defaultBufSize = 4096
32+
eofChar = 0x100
33+
literalDelim uint16 = '"'
3334
)
3435

3536
// Tokenizer is the struct used to generate SQL
@@ -531,7 +532,7 @@ func (tkn *Tokenizer) Scan() (int, []byte) {
531532
var tBytes []byte
532533
ch = tkn.lastChar
533534
tkn.next()
534-
if ch == '`' {
535+
if ch == literalDelim {
535536
tID, tBytes = tkn.scanLiteralIdentifier()
536537
} else {
537538
tID, tBytes = tkn.scanIdentifier(byte(ch), true)
@@ -669,9 +670,9 @@ func (tkn *Tokenizer) Scan() (int, []byte) {
669670
return NE, nil
670671
}
671672
return int(ch), nil
672-
case '\'', '"':
673+
case '\'':
673674
return tkn.scanString(ch, STRING)
674-
case '`':
675+
case literalDelim:
675676
return tkn.scanLiteralIdentifier()
676677
default:
677678
return LEX_ERROR, []byte{byte(ch)}
@@ -771,17 +772,17 @@ func (tkn *Tokenizer) scanLiteralIdentifier() (int, []byte) {
771772
backTickSeen := false
772773
for {
773774
if backTickSeen {
774-
if tkn.lastChar != '`' {
775+
if tkn.lastChar != literalDelim {
775776
break
776777
}
777778
backTickSeen = false
778-
buffer.WriteByte('`')
779+
buffer.WriteByte(byte(literalDelim))
779780
tkn.next()
780781
continue
781782
}
782783
// The previous char was not a backtick.
783784
switch tkn.lastChar {
784-
case '`':
785+
case literalDelim:
785786
backTickSeen = true
786787
case eofChar:
787788
// Premature EOF.
@@ -1066,7 +1067,7 @@ func isLetter(ch uint16) bool {
10661067
}
10671068

10681069
func isCarat(ch uint16) bool {
1069-
return ch == '.' || ch == '\'' || ch == '"' || ch == '`'
1070+
return ch == '.' || ch == '\'' || ch == literalDelim
10701071
}
10711072

10721073
func digitVal(ch uint16) int {

0 commit comments

Comments
 (0)