Add support for array index ranges in SQL queries

This commit is contained in:
Tobie Morgan Hitchcock 2018-05-13 22:14:19 +01:00
parent e120f8961c
commit 74785bd70d

View file

@ -489,14 +489,17 @@ func (s *scanner) scanIdiom(chp ...rune) (tok Token, lit string, val interface{}
break break
} else if isIdentChar(ch) { } else if isIdentChar(ch) {
buf.WriteRune(ch) buf.WriteRune(ch)
} else if isArrayChar(ch) {
tok = EXPR
buf.WriteRune(ch)
} else if isExprsChar(ch) { } else if isExprsChar(ch) {
tok = EXPR tok = EXPR
buf.WriteRune(ch) buf.WriteRune(ch)
} else if ch == ':' { } else if ch == ':' {
if tok == EXPR { if tok == EXPR {
s.undo() buf.WriteRune(ch)
break continue
} }
tbv = buf.String() tbv = buf.String()
@ -1048,9 +1051,14 @@ func isThingChar(ch rune) bool {
return isLetter(ch) || isNumber(ch) || ch == '_' return isLetter(ch) || isNumber(ch) || ch == '_'
} }
// isArrayChar returns true if the rune is allowed in an ARRAY.
func isArrayChar(ch rune) bool {
return ch == '[' || ch == ']'
}
// isExprsChar returns true if the rune is allowed in a IDENT. // isExprsChar returns true if the rune is allowed in a IDENT.
func isExprsChar(ch rune) bool { func isExprsChar(ch rune) bool {
return isLetter(ch) || isNumber(ch) || ch == '.' || ch == '_' || ch == '*' || ch == '[' || ch == '$' || ch == ']' return isLetter(ch) || isNumber(ch) || ch == '.' || ch == '_' || ch == '*' || ch == '$'
} }
// eof represents a marker rune for the end of the reader. // eof represents a marker rune for the end of the reader.