Project

General

Profile

Actions

Defect #36940

closed

Chained custom field filter doesn't work for User fields

Added by Thomas Löber over 2 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Category:
Filters
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

A chained custom field filter doesn't work for fields with format User.

Steps to reproduce:

  1. Create a user custom field A (the format doesn't matter) and check Used as a filter
  2. Create an issue custom field B with format User and check Used as a filter
  3. On the My account page set the custom value A for your own account to an arbitrary value
  4. Create an issue and select <<me>> for the custom field B
  5. Filter the issue list by the filter B's A and use the value you set on the My account page
Expected result:
  • The issue is found
Actual result:
  • The issue is not found

The reason is that the SQL that filters the issues contains a WHERE customized_type='User'. However, the correct clause would be WHERE customized_type='Principal'.

Here is a patch to fix the issue:

--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -1166,7 +1166,7 @@ class Query < ActiveRecord::Base
     end

     filter = available_filters[field]
-    target_class = filter[:through].format.target_class
+    target_class = filter[:through].format.target_class.base_class

     "#{queried_table_name}.id #{not_in} IN (" +
       "SELECT customized_id FROM #{CustomValue.table_name}" +

Best regards,
Thomas


Files

Actions

Also available in: Atom PDF