diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-06-29 13:53:44 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-06-29 13:53:44 +0300 |
commit | cf55dd8b402dc400955039e5617cf701ef1c9930 (patch) | |
tree | 676883e82067ddbbbbea93c093d3b998d0808a97 /app | |
parent | 2dfddddd7b9995439209831e36ab133a66d13cef (diff) | |
parent | eb0d6551161552d33cdc1cfc9dd61fc970158fb5 (diff) |
Merge branch '47769-fix_ambiguous_due_date_for_issue_scopes' into 'master'
Fix ambiguous due_date column for Issue scopes
Closes #47769
See merge request gitlab-org/gitlab-ce!20251
Diffstat (limited to 'app')
-rw-r--r-- | app/models/issue.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index d3df2da14e2..4715d942c8d 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -48,7 +48,7 @@ class Issue < ActiveRecord::Base scope :unassigned, -> { where('NOT EXISTS (SELECT TRUE FROM issue_assignees WHERE issue_id = issues.id)') } scope :assigned_to, ->(u) { where('EXISTS (SELECT TRUE FROM issue_assignees WHERE user_id = ? AND issue_id = issues.id)', u.id)} - scope :with_due_date, -> { where('due_date IS NOT NULL') } + scope :with_due_date, -> { where.not(due_date: nil) } scope :without_due_date, -> { where(due_date: nil) } scope :due_before, ->(date) { where('issues.due_date < ?', date) } scope :due_between, ->(from_date, to_date) { where('issues.due_date >= ?', from_date).where('issues.due_date <= ?', to_date) } @@ -56,7 +56,7 @@ class Issue < ActiveRecord::Base scope :order_due_date_asc, -> { reorder('issues.due_date IS NULL, issues.due_date ASC') } scope :order_due_date_desc, -> { reorder('issues.due_date IS NULL, issues.due_date DESC') } - scope :order_closest_future_date, -> { reorder('CASE WHEN due_date >= CURRENT_DATE THEN 0 ELSE 1 END ASC, ABS(CURRENT_DATE - due_date) ASC') } + scope :order_closest_future_date, -> { reorder('CASE WHEN issues.due_date >= CURRENT_DATE THEN 0 ELSE 1 END ASC, ABS(CURRENT_DATE - issues.due_date) ASC') } scope :preload_associations, -> { preload(:labels, project: :namespace) } |