]> source.dussan.org Git - redmine.git/commitdiff
Searching for issues with "updated = none" always returns zero results (#15226).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 18 Jan 2017 14:57:14 +0000 (14:57 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 18 Jan 2017 14:57:14 +0000 (14:57 +0000)
Patch by Marius BALTEANU.

git-svn-id: http://svn.redmine.org/redmine/trunk@16226 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue_query.rb
test/unit/query_test.rb

index 588a1931d5b6061e1cfba93aec6ea7905d6e8708..53702b9ba294712fb9b5e450c4e91b1700a48e0b 100644 (file)
@@ -449,6 +449,17 @@ class IssueQuery < Query
     end
   end
 
+  def sql_for_updated_on_field(field, operator, value)
+    case operator
+    when "!*"
+      "#{Issue.table_name}.updated_on = #{Issue.table_name}.created_on"
+    when "*"
+      "#{Issue.table_name}.updated_on > #{Issue.table_name}.created_on"
+    else
+      sql_for_field("updated_on", operator, value, Issue.table_name, "updated_on")
+    end
+  end
+
   def sql_for_issue_id_field(field, operator, value)
     if operator == "="
       # accepts a comma separated list of ids
index e6761c21150306c4b086abdc99f3f8d623c3e60c..8b88b11cd924ffecccdad7acc46c2c213390a59c 100644 (file)
@@ -1900,4 +1900,19 @@ class QueryTest < ActiveSupport::TestCase
     assert_equal [1, 2, 3, 6, 7, 8, 9, 10, 11, 12], issues.map(&:id).sort
   end
 
+  def test_filter_updated_on_none_should_return_issues_with_updated_on_equal_with_created_on
+    query = IssueQuery.new(:name => '_', :project => Project.find(1))
+
+    query.filters = {'updated_on' => {:operator => '!*', :values => ['']}}
+    issues = find_issues_with_query(query)
+    assert_equal [3, 6, 7, 8, 9, 10, 14], issues.map(&:id).sort
+  end
+
+  def test_filter_updated_on_any_should_return_issues_with_updated_on_greater_than_created_on
+    query = IssueQuery.new(:name => '_', :project => Project.find(1))
+
+    query.filters = {'updated_on' => {:operator => '*', :values => ['']}}
+    issues = find_issues_with_query(query)
+    assert_equal [1, 2, 5, 11, 12, 13], issues.map(&:id).sort
+  end
 end