233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
# File 'lib/active_record/turntable/sql_tree_patch.rb', line 233
def self.parse_rhs(tokens, precedence, operator = nil)
if ["IN", "NOT IN"].include?(operator)
if SQLTree::Token::SELECT === tokens.peek(2)
return SQLTree::Node::SubQuery.parse(tokens)
else
return List.parse(tokens)
end
elsif ["IS", "IS NOT"].include?(operator)
tokens.consume(SQLTree::Token::NULL)
return SQLTree::Node::Expression::Value.new(nil)
elsif ["BETWEEN"].include?(operator)
expr = parse_atomic(tokens)
operator = parse_operator(tokens)
rhs = parse_rhs(tokens, precedence, operator)
expr = self.new(operator: operator, lhs: expr, rhs: rhs)
return expr
else
return parse(tokens, precedence + 1)
end
end
|