mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-15 07:36:41 +10:00
Fix UNION syntax for MySQL
Apparently MySQL doesn't support this syntax:
(...) UNION (...)
instead it only supports:
...
UNION
...
This commit is contained in:
@@ -23,11 +23,11 @@ module Gitlab
|
||||
# (thus fixing this problem), at a slight performance cost.
|
||||
fragments = ActiveRecord::Base.connection.unprepared_statement do
|
||||
@relations.map do |rel|
|
||||
"(#{rel.reorder(nil).to_sql})"
|
||||
rel.reorder(nil).to_sql
|
||||
end
|
||||
end
|
||||
|
||||
fragments.join(' UNION ')
|
||||
fragments.join("\nUNION\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ describe Gitlab::SQL::Union do
|
||||
sql1 = rel1.reorder(nil).to_sql
|
||||
sql2 = rel2.reorder(nil).to_sql
|
||||
|
||||
expect(union.to_sql).to eq("(#{sql1}) UNION (#{sql2})")
|
||||
expect(union.to_sql).to eq("#{sql1}\nUNION\n#{sql2}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user