Project

General

Profile

Actions

Defect #26863

closed

file: issue_query.rb function:sql_for_issue_id_field line: ids = value.first.to_s.scan(/\d+/).map(&:to_i) should the first to be deleted?

Added by jiangshan song over 6 years ago. Updated over 6 years ago.

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

0%

Estimated time:
Resolution:
Invalid
Affected version:

Description

I'm writing a redmine plugin using: IssueQuery
where when I want to use :
myquery.add_filter("issue_id" , "=", ["123", "124","125"])
I got only the first issue.
finally i find the function:sql_for_issue_id_field

  def sql_for_issue_id_field(field, operator, value)
    if operator == "=" 
      # accepts a comma separated list of ids
      ids = value.first.to_s.scan(/\d+/).map(&:to_i)
      if ids.present?
        "#{Issue.table_name}.id IN (#{ids.join(",")})" 
      else
        "1=0" 
      end
    else
      sql_for_field("id", operator, value, Issue.table_name, "id")
    end
  end

I seems that the "first" is a error?

BTW: i'm new to ruby and redmine.

Actions #1

Updated by jiangshan song over 6 years ago

I changed "ids = value.first.to_s.scan(/\d+/).map(&:to_i)" to "ids = value.to_s.scan(/\d+/).map(&:to_i)"
it seems work.

Actions #2

Updated by Toshi MARUYAMA over 6 years ago

  • Description updated (diff)
Actions #3

Updated by Toshi MARUYAMA over 6 years ago

  • Status changed from New to Closed
  • Resolution set to Invalid

source:tags/3.4.2/test/unit/query_test.rb#L277

query.add_filter("issue_id", '=', ['1,3'])

Actions

Also available in: Atom PDF