You need to sign in or sign up before continuing.
Add code helper for selecting from a UNION
In a whole bunch of places we essentially have this pattern:
union = Gitlab::SQL::Union.new([foo, bar])
SomeModel.from("(#{union.to_sql}) #{SomeModel.table_name}")
This pattern exists because we found that selecting from a UNION, instead of a WHERE IN, produces more reliable / better query plans. Instead of repeating this particular pattern over and over, we should add some kind of from_union
method that takes care of this.