]> source.dussan.org Git - redmine.git/commitdiff
Merged r21684 and r21685 to 4.2-stable (#37349).
authorMarius Balteanu <marius.balteanu@zitec.com>
Tue, 28 Jun 2022 06:48:06 +0000 (06:48 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Tue, 28 Jun 2022 06:48:06 +0000 (06:48 +0000)
git-svn-id: https://svn.redmine.org/redmine/branches/4.2-stable@21689 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index 3891cc456d6fcc126aaddf6e117ccda95ae9aac1..4f9b9d7a8d5c145a4a88222371326a1eebbd86ca 100644 (file)
@@ -1176,7 +1176,7 @@ class Query < ActiveRecord::Base
       "  AND CAST(CASE value WHEN '' THEN '0' ELSE value END AS decimal(30,0)) IN (" +
       "  SELECT customized_id FROM #{CustomValue.table_name}" +
       "  WHERE customized_type='#{target_class}' AND custom_field_id=#{chained_custom_field_id}" +
-      "  AND #{sql_for_field(field, operator, value, CustomValue.table_name, 'value')}))"
+      "  AND #{sql_for_field(field, operator, value, CustomValue.table_name, 'value', true)}))"
 
   end
 
index 54d0c06d2c82db8cdad34e1eff7d2ed8b2ab4381..fec143e8b64e587a3d13debb98bfb7ede602013f 100644 (file)
@@ -907,6 +907,18 @@ class QueryTest < ActiveSupport::TestCase
     assert_equal issue1, result.first
   end
 
+  def test_filter_on_chained_user_custom_field_of_type_float
+    user_cf = UserCustomField.find(5)
+    user_cf.update! is_filter: true
+
+    issue_cf = IssueCustomField.create!(:field_format => 'user', :is_for_all => true, :is_filter => true, :name => 'User custom field', :tracker_ids => [1])
+    issue1 = Issue.create!(:project_id => 1, :tracker_id => 1, :custom_field_values => {issue_cf.id.to_s => '2'}, :subject => 'Test', :author_id => 1)
+    query = IssueQuery.new(:name => '_', :project => Project.find(1))
+    query.filters = {"cf_#{issue_cf.id}.cf_#{user_cf.id}" => {:operator => '=', :values => ["30.1"]}}
+
+    assert query.issues
+  end
+
   def test_filter_on_me_by_anonymous_user
     User.current = nil
     query =