Commit b62825fd authored by Yorick Peterse's avatar Yorick Peterse

Merge branch...

Merge branch 'blackst0ne-rails5-activerecord-statementinvalid-mysql2-error-expression-1-of-select-list-is-not-in-group-by-clause' into 'master'

[Rails5] Fix milestone GROUP BY query

Closes #48428

See merge request gitlab-org/gitlab-ce!20256
parents 34fe3274 98b1f549
...@@ -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