Defect #26863

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 4 years ago. Updated over 4 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-
Resolution:Invalid Affected version:3.4.2

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.

History

#1 Updated by jiangshan song over 4 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.

#2 Updated by Toshi MARUYAMA over 4 years ago

  • Description updated (diff)

#3 Updated by Toshi MARUYAMA over 4 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'])

Also available in: Atom PDF