Project

General

Profile

Actions

Patch #20124

open

Query option, The sql for field to allow groups option.

Added by Rupesh J almost 9 years ago. Updated about 8 years ago.

Status:
New
Priority:
High
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

The simple commit help abundantly and allow us to grouping the custom queries.
When the available filters is added with the field name, the check already exists for sql field statement.
Another check is added when the field is added with grouping.

Please update this patch in the core.

Thanks.


Files

Actions #1

Updated by Rupesh J almost 9 years ago

The advantage of this patch, is that I do not need to alias the sql_for_field method in my plugin!
I am also open for more elegant solution.
Thanks.

Actions #2

Updated by Toshi MARUYAMA about 8 years ago

  • Status changed from New to Needs feedback

Where is $2 from?
field =~ /^(.+)\./ returns only $1.

Actions #3

Updated by Rupesh J about 8 years ago

For the below cases, With grouping of filters,

Suppose, If I add a custom filter through a plugin patch

     add_available_filter("question.qassigned_to_id", :type => :list, :values => author_values,
         :caption => :field_question_assigned_to_id, :name => l(:field_question_assigned_to_id_esi)
     )

The only way to handle the corresponding SQL query is to alias the sql_for_field.
Instead if the attached patch is provided,
I can avoid the alias and also have my method,

    def sql_for_qassigned_to_id_field(.....)
      .... sql logic...
    end

Thank You.

Actions #4

Updated by Toshi MARUYAMA about 8 years ago

In your sql_for_fields_with_group-git.diff

      elsif field =~ /^(.+)\./ && respond_to?("sql_for_#{$2}_field")
        # specific statement
        filters_clauses << send("sql_for_#{$2}_field", field, operator, v)

http://ruby-doc.org/core-2.1.1/Regexp.html#class-Regexp-label-Special+global+variables

$1, $2 and so on contain text matching first, second, etc capture group;

But your field =~ /^(.+)\./ has only one parenthesis.

Actions #5

Updated by Rupesh J about 8 years ago

Yes, Realized my mistake. Thank You.
Here is the Updated patch.

Thanks.

Actions #6

Updated by Toshi MARUYAMA about 8 years ago

  • Status changed from Needs feedback to New
Actions

Also available in: Atom PDF