lib/elastic_apm/sql/tokenizer.rb in elastic-apm-4.0.0.beta.1 vs lib/elastic_apm/sql/tokenizer.rb in elastic-apm-4.0.0.beta.2
- old
+ new
@@ -67,11 +67,11 @@
when '`' then scan_quoted_indentifier('`')
when '"' then scan_quoted_indentifier('"')
when '[' then scan_quoted_indentifier(']')
when '(' then LPAREN
when ')' then RPAREN
- when '/' then scan_bracketed_comment
+ when '/' then scan_bracketed_or_cql_comment
when '-' then scan_simple_comment
when "'" then scan_string_literal
when ALPHA then scan_keyword_or_identifier(possible_keyword: true)
when DIGIT then scan_numeric_literal
else OTHER
@@ -183,14 +183,20 @@
@byte_end -= char.bytesize
IDENT
end
+ def scan_bracketed_or_cql_comment
+ case peek_char
+ when '*' then scan_bracketed_comment
+ when '/' then scan_cql_comment
+ else OTHER
+ end
+ end
+
# rubocop:disable Metrics/CyclomaticComplexity
def scan_bracketed_comment
- return OTHER unless peek_char == '*'
-
nesting = 1
while (char = next_char)
case char
when '/'
@@ -204,9 +210,19 @@
return COMMENT if nesting == 0
end
end
end
# rubocop:enable Metrics/CyclomaticComplexity
+
+ def scan_cql_comment
+ return OTHER unless peek_char == '/'
+
+ while (char = next_char)
+ break if char == "\n"
+ end
+
+ COMMENT
+ end
def scan_simple_comment
return OTHER unless peek_char == '-'
while (char = next_char)