partition_overwrites(lhs_wheres, rhs_wheres)
private
Remove equalities from the
existing relation with a LHS which is present in the relation being merged
in. returns [things_to_remove, things_to_keep]
Show source
def partition_overwrites(lhs_wheres, rhs_wheres)
if lhs_wheres.empty? || rhs_wheres.empty?
return [[], lhs_wheres]
end
nodes = rhs_wheres.find_all do |w|
w.respond_to?(:operator) && w.operator == :==
end
seen = Set.new(nodes) { |node| node.left }
lhs_wheres.partition do |w|
w.respond_to?(:operator) && w.operator == :== && seen.include?(w.left)
end
end