diff options
author | blackst0ne <blackst0ne.ru@gmail.com> | 2018-07-06 12:41:01 +1100 |
---|---|---|
committer | blackst0ne <blackst0ne.ru@gmail.com> | 2018-07-06 12:41:01 +1100 |
commit | 98b1f5496ce47ea09e6cc57a503995e0ceadb254 (patch) | |
tree | 325028a9a1f266dff1cee83f93aca71e30237084 | |
parent | d810e65a18a87c00c7193b2431fdf72546649768 (diff) | |
download | gitlab-ce-98b1f5496ce47ea09e6cc57a503995e0ceadb254.tar.gz |
[Rails5] Fix milestone GROUP BY query
-rw-r--r-- | app/models/milestone.rb | 3 | ||||
-rw-r--r-- | changelogs/unreleased/blackst0ne-rails5-activerecord-statementinvalid-mysql2-error-expression-1-of-select-list-is-not-in-group-by-clause.yml | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/app/models/milestone.rb b/app/models/milestone.rb index d05dcfd083a..14cc12b38a5 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -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 diff --git a/changelogs/unreleased/blackst0ne-rails5-activerecord-statementinvalid-mysql2-error-expression-1-of-select-list-is-not-in-group-by-clause.yml b/changelogs/unreleased/blackst0ne-rails5-activerecord-statementinvalid-mysql2-error-expression-1-of-select-list-is-not-in-group-by-clause.yml new file mode 100644 index 00000000000..d9cccc49830 --- /dev/null +++ b/changelogs/unreleased/blackst0ne-rails5-activerecord-statementinvalid-mysql2-error-expression-1-of-select-list-is-not-in-group-by-clause.yml @@ -0,0 +1,5 @@ +--- +title: "[Rails5] Fix milestone GROUP BY query" +merge_request: 20256 +author: "@blackst0ne" +type: fixed |