Commit 98b1f549 authored by blackst0ne's avatar blackst0ne

[Rails5] Fix milestone GROUP BY query

parent d810e65a
...@@ -131,9 +131,10 @@ class Milestone < ActiveRecord::Base ...@@ -131,9 +131,10 @@ class Milestone < ActiveRecord::Base
rel.order(:project_id, :due_date).select('DISTINCT ON (project_id) id') rel.order(:project_id, :due_date).select('DISTINCT ON (project_id) id')
else else
rel rel
.group(:project_id) .group(:project_id, :due_date, :id)
.having('due_date = MIN(due_date)') .having('due_date = MIN(due_date)')
.pluck(:id, :project_id, :due_date) .pluck(:id, :project_id, :due_date)
.uniq(&:second)
.map(&:first) .map(&:first)
end end
end end
......
---
title: "[Rails5] Fix milestone GROUP BY query"
merge_request: 20256
author: "@blackst0ne"
type: fixed
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