mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
b1356cb2fa
Related #39644.
Historically subclasses of `Equality` has a special equality ability,
but it has migrated to `equality?` method.
Since we have added `HomogeneousIn`, `Equality === node` could no longer
detect all equality nodes, we should check the response of `equality?`
method for the purpose.
Originally, it wasn't common understanding that the `In` node was a
subclass of the `Equality` node, so it was unclear whether
`Equality === node` really wanted to detect the `In` node as well.
As another problem, we need to check `In === node` first if intend to
detect only `Equality` node.
Example:
4148590ed9/activerecord/lib/active_record/relation/where_clause.rb (L98-L103)
This solves the problems described above.
15 lines
258 B
Ruby
15 lines
258 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Arel # :nodoc: all
|
|
module Nodes
|
|
class In < Arel::Nodes::Binary
|
|
include FetchAttribute
|
|
|
|
def equality?; true; end
|
|
|
|
def invert
|
|
Arel::Nodes::NotIn.new(left, right)
|
|
end
|
|
end
|
|
end
|
|
end
|