Defect #19273

acts_as_searchable.rb only seems to be case insensitive if postgresql

Added by Marc Tardif over 7 years ago. Updated about 7 years ago.

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


Category:Search engine
Target version:-
Resolution:Invalid Affected version:3.0.0


In acts_as_searchable.rb, I see the following code:

          def search_token_match_statement(column, value='?')
            if Redmine::Database.postgresql?
              if Redmine::Database.postgresql_unaccent?
                "unaccent(#{column}) ILIKE unaccent(#{value})" 
                "#{column} ILIKE #{value}" 
              "#{column} LIKE #{value}" 

It seems that the last else statement should read something like "LOWER(#{column}) LIKE #{value.lowercase}". I believe that's what Redmine pre-3 did.

Related issues

Related to Redmine - Defect #20042: A test fail when running it with PostgreSQL Needs feedback


#1 Updated by Toshi MARUYAMA over 7 years ago

  • Target version set to 3.0.1

#2 Updated by Toshi MARUYAMA over 7 years ago

  • Description updated (diff)

#3 Updated by Jean-Philippe Lang over 7 years ago

  • Status changed from New to Closed
  • Target version deleted (3.0.1)
  • Resolution set to Invalid

No, LIKE is case insensitive for databases other than PostgreSQL. Have a look at SearchTest#test_search_should_be_case_insensitive:

#4 Updated by Vincent Robert about 7 years ago

I don't know if it's related, but when running the test suite against PostgreSQL, this test fails:

Minitest::Assertion: "Bug #16: Special chars: Öö" not found in "[#<Issue id: 15, tracker_id: 1, project_id: 1, subject: "Special chars: ÖÖ", description: nil, due_date: nil, category_id: nil, status_id: 1, assigned_to_id: nil, priority_id: 5, fixed_version_id: nil, author_id: 2, lock_version: 0, created_on: "2015-04-27 10:19:13", updated_on: "2015-04-27 10:19:13", start_date: nil, done_ratio: 0, estimated_hours: nil, parent_id: nil, root_id: 15, lft: 1, rgt: 2, is_private: false, closed_on: nil>]" 
test/unit/search_test.rb:159:in `test_search_should_be_case_insensitive_with_accented_characters'

#5 Updated by Toshi MARUYAMA about 7 years ago

  • Related to Defect #20042: A test fail when running it with PostgreSQL added

Also available in: Atom PDF