Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set collation for postgresql test DBs. #45715

Merged
merged 1 commit into from Jul 31, 2022

Conversation

simi
Copy link
Contributor

@simi simi commented Jul 31, 2022

I was facing test failures related to different order than expected since I have lc_collate set to cs_CZ.UTF-8.

I propose to set lc_collate on test DB creation to en_US.UTF-8. Similar strategy is used also for MySQL at

rails/activerecord/Rakefile

Lines 223 to 224 in a01d6f8

%x( mysql #{connection_arguments["arunit"]} -e "create DATABASE #{config["arunit"]["database"]} DEFAULT CHARACTER SET utf8mb4" )
%x( mysql #{connection_arguments["arunit2"]} -e "create DATABASE #{config["arunit2"]["database"]} DEFAULT CHARACTER SET utf8mb4" )
.

example failure (fixed by this PR)

Using postgresql                                                                                                                                                                   [2260/7680]
Run options: --seed 10882                                                                                                                                                                     
                                                                                                                                                                                              
# Running:                                                                                                                                                                                    
                                                                                                                                                                                              
.................................F                                                                                                                                                            
                                                                                                                                                                                              
Failure:                                                                                                                                                                                      
CalculationsTest#test_pluck_loaded_relation_sql_fragment [test/cases/calculations_test.rb:1081]:                                                                                              
--- expected                                                                                                                                                                                  
+++ actual                                                                                                                                                                                    
@@ -1 +1 @@                                                                                                                                                                                   
-["37signals", "Apex", "Ex Nihilo"]                                                                                                                                                           
+["Apex", "Ex Nihilo", "Ex Nihilo Part Deux"]                                                                                                                                                 
                                                                                                                                                                                              
                                                                                                                                                                                              
                                                                                                                                                                                              
rails test test/cases/calculations_test.rb:1078                                                                                                                                               
                                                                                                                                                                                              
......................................................................................................S..F                                                                                    
                                                                                                                                                                                              
Failure:                                                                                                                                                                                      
CalculationsTest#test_pick_loaded_relation_sql_fragment [test/cases/calculations_test.rb:1138]:                                                                                               
Expected: "37signals"                                                                                                                                                                         
  Actual: "Apex"                                                                                                                                                                              
                                                                                                                                                                                              
                                                                                                                                                                                              
rails test test/cases/calculations_test.rb:1135                                                                                                                                               
                                                                                                                                                                                              
....................................................                                                                                                                                          
                                                                                                                                                                                              
Finished in 1.409349s, 136.2331 runs/s, 366.1265 assertions/s.                                                                                                                                
192 runs, 516 assertions, 2 failures, 0 errors, 1 skips   

@yahonda yahonda merged commit 0098f55 into rails:main Jul 31, 2022
@simi simi deleted the postgresql-test-collation branch July 31, 2022 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants