Fix UNION syntax for MySQL

Apparently MySQL doesn't support this syntax:

    (...) UNION (...)

instead it only supports:

    ...
    UNION
    ...
This commit is contained in:
Yorick Peterse
2015-11-18 13:31:18 +01:00
parent cc11c44ba9
commit 9eefae6917
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -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
+1 -1
View File
@@ -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