diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2018-07-06 12:16:37 +0000 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2018-07-06 12:16:37 +0000 |
commit | b62825fd8e9c2215a270675a1209442fd1d38b30 (patch) | |
tree | 5b207dc4e9aaeabfadf3c6a7df56aa7feb600405 | |
parent | 34fe32740f475051dfcbb696f11c270ae327dc4a (diff) | |
parent | 98b1f5496ce47ea09e6cc57a503995e0ceadb254 (diff) | |
download | gitlab-ce-b62825fd8e9c2215a270675a1209442fd1d38b30.tar.gz |
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
-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 |