Defect #19273

acts_as_searchable.rb only seems to be case insensitive if postgresql

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

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

0%

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

Description

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})" 
              else
                "#{column} ILIKE #{value}" 
              end
            else
              "#{column} LIKE #{value}" 
            end
          end

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

History

#1 Updated by Toshi MARUYAMA over 6 years ago

  • Target version set to 3.0.1

#2 Updated by Toshi MARUYAMA over 6 years ago

  • Description updated (diff)

#3 Updated by Jean-Philippe Lang over 6 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:
source:/tags/3.0.0/test/unit/search_test.rb#L145

#4 Updated by Vincent Robert about 6 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 6 years ago

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

Also available in: Atom PDF