Select Git revision
merge_requests_finder.rb
-
Stan Hu authored
When adding a `Approved By` or `Approver` filter and sorting by milestone, a 500 error will occur because of a SQL error: ``` PG::GroupingError: ERROR: column "milestones.due_date" must appear in the GROUP BY clause or be used in an aggregate function ``` This happens because the approval query uses a `GROUP BY` query to find merge requests that match all approvers. However, this `GROUP BY` query breaks the SQL query since it's expected that `milestones.due_date` and `milestones.id` are present in that clause. We can solve this problem in a few ways: 1. Add the required grouping columns to this query (this commit). 2. Use a CTE to isolate the query for approvers. 3. Rewrite the approvers query to avoid the GROUP BY altogether. The second way appears to work, but there's a risk of running into errors due to nested queries. Plus, it does not appear the CTE improves performance. The third way may also be possible, but it would possibly require some schema changes or other refactoring. For now, we can solve this problem by manually adding the required grouping columns when approvers are specified. Relates to #223062 Changelog: fixed
Stan Hu authoredWhen adding a `Approved By` or `Approver` filter and sorting by milestone, a 500 error will occur because of a SQL error: ``` PG::GroupingError: ERROR: column "milestones.due_date" must appear in the GROUP BY clause or be used in an aggregate function ``` This happens because the approval query uses a `GROUP BY` query to find merge requests that match all approvers. However, this `GROUP BY` query breaks the SQL query since it's expected that `milestones.due_date` and `milestones.id` are present in that clause. We can solve this problem in a few ways: 1. Add the required grouping columns to this query (this commit). 2. Use a CTE to isolate the query for approvers. 3. Rewrite the approvers query to avoid the GROUP BY altogether. The second way appears to work, but there's a risk of running into errors due to nested queries. Plus, it does not appear the CTE improves performance. The third way may also be possible, but it would possibly require some schema changes or other refactoring. For now, we can solve this problem by manually adding the required grouping columns when approvers are specified. Relates to #223062 Changelog: fixed
Code owners
Assign users and groups as approvers for specific file changes. Learn more.