Project

General

Profile

Actions

Defect #20042

closed

A test fail when running it with PostgreSQL

Added by Vincent Robert almost 9 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Code cleanup/refactoring
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

When running the test suite with 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'

Related issues

Related to Redmine - Defect #19273: acts_as_searchable.rb only seems to be case insensitive if postgresqlClosed

Actions
Actions #1

Updated by Toshi MARUYAMA almost 9 years ago

  • Status changed from New to Needs feedback
  • Resolution set to Cant reproduce
Actions #2

Updated by Toshi MARUYAMA almost 9 years ago

  • Related to Defect #19273: acts_as_searchable.rb only seems to be case insensitive if postgresql added
Actions #3

Updated by Vincent Robert almost 9 years ago

Using PostgreSQL 9.3.1, with a fresh install on Mac OS X, without any plugin, I get this failure:

redmine-3.0.3: ruby test/unit/search_test.rb
Run options: --seed 51093

# Running:

.......F.

Finished in 1.519564s, 5.9228 runs/s, 21.0587 assertions/s.

  1) Failure:
SearchTest#test_search_should_be_case_insensitive_with_accented_characters [test/unit/search_test.rb:159]:
"Bug #18: Special chars: Öö" not found in "[#<Issue id: 17, 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-06-15 07:51:24", updated_on: "2015-06-15 07:51:24", start_date: nil, done_ratio: 0, estimated_hours: nil, parent_id: nil, root_id: 17, lft: 1, rgt: 2, is_private: false, closed_on: nil>]" 

9 runs, 32 assertions, 1 failures, 0 errors, 0 skips
Environment:
  Redmine version                3.0.3.stable
  Ruby version                   2.2.2-p95 (2015-04-13) [x86_64-darwin14]
  Rails version                  4.2.1
Actions #4

Updated by Ko Nagase about 3 years ago

Well, I encountered the same error on the latest master (trunk, 4.1+) on macOS Mojave (10.14.6) and PostgreSQL 13.1 (from Homebrew).


$ bundle exec rails test test/unit/search_test.rb:153
Run options: --seed 50546

# Running:

F

Failure:
SearchTest#test_search_should_be_case_insensitive_with_accented_characters [/path/to/redmine/test/unit/search_test.rb:159]:
"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: "2021-01-18 07:49:29", updated_on: "2021-01-18 07:49:29", 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>]" 

bin/rails test test/unit/search_test.rb:153

Finished in 0.533460s, 1.8746 runs/s, 3.7491 assertions/s.
1 runs, 2 assertions, 1 failures, 0 errors, 0 skip

But, after enabling unaccent extension on PostgreSQL, then the test was passed.
https://stackoverflow.com/questions/11005036/does-postgresql-support-accent-insensitive-collations/11007216#11007216


$ psql -U postgres redmine_test
# CREATE EXTENSION unaccent;
# \q
$ bundle exec rails test test/unit/search_test.rb:153
Run options: --seed 21594

# Running:

.

Finished in 0.535496s, 1.8674 runs/s, 3.7349 assertions/s.
1 runs, 2 assertions, 0 failures, 0 errors, 0 skips

So, I think that this is PostgreSQL environment related issue.

Actions #5

Updated by Ko Nagase over 1 year ago

From the past PostgreSQL accent insensitive search issue (#18801) and the following r13989 diffs,

I think that the same purpose test is done in "test_search_should_be_case_and_accent_insensitive_with_postgresql_and_noaccent_extension" for PostgreSQL, so failed test is not necessary for PostgreSQL.

With the following changes, I confirmed that all test passed in macOS environment.

--- a/test/unit/search_test.rb
+++ b/test/unit/search_test.rb
@@ -175,7 +175,7 @@ class SearchTest < ActiveSupport::TestCase
   end

   def test_search_should_be_case_insensitive_with_accented_characters
-    unless sqlite?
+    unless sqlite? || postgresql?
       issue1 = Issue.generate!(:subject => "Special chars: ÖÖ")
       issue2 = Issue.generate!(:subject => "Special chars: Öö")
       r = Issue.search_results('ÖÖ')

Above changes can be replaced to "if mysql?", but in that case, checking #18537 issue and the following r13767 changes may be necessary.
Actions #6

Updated by Go MAEDA over 1 year ago

  • Category set to Code cleanup/refactoring
  • Status changed from Needs feedback to New
  • Target version set to 5.1.0
  • Resolution deleted (Cant reproduce)

Ko Nagase wrote:

From the past PostgreSQL accent insensitive search issue (#18801) and the following r13989 diffs,

I think that the same purpose test is done in "test_search_should_be_case_and_accent_insensitive_with_postgresql_and_noaccent_extension" for PostgreSQL, so failed test is not necessary for PostgreSQL.

With the following changes, I confirmed that all test passed in macOS environment.
[...]

Thank you for investigating the issue. I will commit the fix you suggested in #20042#note-5.

Setting the target version to 5.1.0.

Actions #7

Updated by Go MAEDA over 1 year ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch. Thank you.

Actions

Also available in: Atom PDF