[Rails5] Fix milestone GROUP BY query

This commit is contained in:
blackst0ne 2018-07-06 12:41:01 +11:00
parent d810e65a18
commit 98b1f5496c
2 changed files with 7 additions and 1 deletions

View File

@ -131,9 +131,10 @@ class Milestone < ActiveRecord::Base
rel.order(:project_id, :due_date).select('DISTINCT ON (project_id) id')
else
rel
.group(:project_id)
.group(:project_id, :due_date, :id)
.having('due_date = MIN(due_date)')
.pluck(:id, :project_id, :due_date)
.uniq(&:second)
.map(&:first)
end
end

View File

@ -0,0 +1,5 @@
---
title: "[Rails5] Fix milestone GROUP BY query"
merge_request: 20256
author: "@blackst0ne"
type: fixed