Skip to content
Browse files

Make sure recreate MySQL test database with the proper encoding and c…

…ollation [#1165 state:resolved]

Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1165 state:committed]
  • Loading branch information...
1 parent 7553a23 commit 1bc267d21679408b3624d1c697656ec250c01972 Luca Guidi committed with NZKoz Oct 3, 2008
View
4 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -371,9 +371,9 @@ def structure_dump #:nodoc:
end
end
- def recreate_database(name) #:nodoc:
+ def recreate_database(name, options = {}) #:nodoc:
drop_database(name)
- create_database(name)
+ create_database(name, options)
end
# Create a new MySQL database with optional <tt>:charset</tt> and <tt>:collation</tt>.
View
5 activerecord/test/cases/active_schema_test_mysql.rb
@@ -25,6 +25,11 @@ def test_create_mysql_database_with_encoding
assert_equal "CREATE DATABASE `aimonetti` DEFAULT CHARACTER SET `latin1`", create_database(:aimonetti, {:charset => 'latin1'})
assert_equal "CREATE DATABASE `matt_aimonetti` DEFAULT CHARACTER SET `big5` COLLATE `big5_chinese_ci`", create_database(:matt_aimonetti, {:charset => :big5, :collation => :big5_chinese_ci})
end
+
+ def test_recreate_mysql_database_with_encoding
+ create_database(:luca, {:charset => 'latin1'})
+ assert_equal "CREATE DATABASE `luca` DEFAULT CHARACTER SET `latin1`", recreate_database(:luca, {:charset => 'latin1'})
+ end
end
def test_add_column
View
2 railties/lib/tasks/databases.rake
@@ -341,7 +341,7 @@ namespace :db do
case abcs["test"]["adapter"]
when "mysql"
ActiveRecord::Base.establish_connection(:test)
- ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"])
+ ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"], abcs["test"])
when "postgresql"
ActiveRecord::Base.clear_active_connections!
drop_database(abcs['test'])

0 comments on commit 1bc267d

Please sign in to comment.
Something went wrong with that request. Please try again.