Commit a5aa1d2f authored by Kamil Trzciński's avatar Kamil Trzciński

Fix MySQL

parent c0926dc2
......@@ -198,7 +198,12 @@ module Ci
def self.newest_first(ref: nil, limit: 100)
relation = order(id: :desc)
relation = relation.where(ref: ref) if ref
relation = relation.where(id: relation.limit(limit).select(:id)) if limit
if limit
ids = relation.limit(limit).select(:id)
# MySQL does not support limit in subquery
ids = ids.pluck(:id) if Gitlab::Database.mysql?
relation = relation.where(id: ids)
end
relation
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment