Module: ActiveRecordExtended::Patch::RelationPatch::Merger

Defined in:
lib/active_record_extended/patch/relation_patch.rb

Instance Method Summary collapse

Instance Method Details

#mergeObject



20
21
22
23
24
25
# File 'lib/active_record_extended/patch/relation_patch.rb', line 20

def merge
  merge_ctes!
  merge_union!
  merge_windows!
  super
end

#merge_ctes!Object



41
42
43
44
45
46
47
48
49
# File 'lib/active_record_extended/patch/relation_patch.rb', line 41

def merge_ctes!
  return unless other.with_values?

  if other.recursive_value? && !relation.recursive_value?
    relation.with!.recursive(other.cte)
  else
    relation.with!(other.cte)
  end
end

#merge_union!Object



27
28
29
30
31
32
33
# File 'lib/active_record_extended/patch/relation_patch.rb', line 27

def merge_union!
  return if other.unionize_storage.empty?

  relation.union_values          += other.union_values
  relation.union_operations      += other.union_operations
  relation.union_ordering_values += other.union_ordering_values
end

#merge_windows!Object



35
36
37
38
39
# File 'lib/active_record_extended/patch/relation_patch.rb', line 35

def merge_windows!
  return unless other.window_values?

  relation.window_values |= other.window_values
end