Skip to content

Commit

Permalink
Fix: parse identifier with backquote
Browse files Browse the repository at this point in the history
  • Loading branch information
matsubara0507 committed Nov 13, 2020
1 parent 25fc12d commit 5e90d11
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/active_record/turntable/sql_tree_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def each_token(&block) # :yields: SQLTree::Token
when /\w/; tokenize_keyword(&block)
when OPERATOR_CHARS; tokenize_operator(&block)
when SQLTree.identifier_quote_char; tokenize_quoted_identifier(&block)
when SQLTree.identifier_quote_field_char; tokenize_identifier_with_quote(&block)
end
end

Expand All @@ -73,6 +74,14 @@ def tokenize_possible_escaped_string(&block)
tokenize_keyword(&block)
end
end

def tokenize_identifier_with_quote(&block)
next_char # skip identifier_quote_field_char
literal = current_char
literal << next_char while SQLTree.identifier_quote_field_char != peek_char
next_char # skip identifier_quote_field_char
handle_token(SQLTree::Token::Identifier.new(literal), &block)
end
end

module SQLTree::Node
Expand Down

0 comments on commit 5e90d11

Please sign in to comment.