プロジェクト

全般

プロフィール

Vote #79651

完了

Empty sort criteria for issue query gives error

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Issues_2
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
2
version_id:
143
issue_org_id:
30009
author_id:
342597
assigned_to_id:
332
comments:
10
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

When saving an Issue query,provide the sort criteria like below, i.e leaving the middle one empty.

!sort.PNG!

Save the query.

With the new query loaded,click on apply.

It gives error.

Bug occured on redmine: 3.4.6


journals

I could not reproduce the problem. Can you see any error regarding this problem in log/production.log ?
--------------------------------------------------------------------------------
It is reproducible on a clean install of Redmine 3.4.6.
After you save the query,make sure the same query is loaded & click apply.

Since the middle criteria for sort is left empty,the to_param method in Redmine::SortCriteria throws "undefined method `+' for nil:NilClass" error.
--------------------------------------------------------------------------------
I can confirm the defect. It also occurs on the latest trunk.
Switching the query works as expected. As Kumar wrote it only occurs after applying the query a second time.
--------------------------------------------------------------------------------
Kumar Abhinav wrote:
> After you save the query,make sure the same query is loaded & click apply.

Yes, I didn't click "Apply" after creating the query. Now I can reproduce the problem.
--------------------------------------------------------------------------------
Attached a patch that fixes this problem by removing the blank keys from sort criteria.

Another fix is the below one, but I prefer the first solution.
<pre><code class="diff">
diff --git a/lib/redmine/sort_criteria.rb b/lib/redmine/sort_criteria.rb
index c89ef03c1..acfcbdb0f 100644
--- a/lib/redmine/sort_criteria.rb
+++ b/lib/redmine/sort_criteria.rb
@@ -32,7 +32,7 @@ module Redmine
end

def to_param
- self.collect {|k,o| k + (o == 'desc' ? ':desc' : '')}.join(',')
+ self.collect {|k,o| k + (o == 'desc' ? ':desc' : '') unless k.nil? }.join(',')
end

def to_a

</code></pre>

Also, maybe it is a good idea to fix this issue also in the UI by not allowing to select a third sort criteria without selecting the second.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Committed the patch. Thank you for the patch.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

relates,Closed,32737,Duplicate sort keys for issue query cause SQL error with SQL Server

Admin Redmine さんが3年以上前に更新

  • カテゴリIssues_2 にセット
  • 対象バージョン3.4.7_143 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0