aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/CHANGELOG4
-rwxr-xr-xactiverecord/lib/active_record/connection_adapters/mysql_adapter.rb2
-rw-r--r--activerecord/test/active_schema_test_mysql.rb4
3 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 4b962e43a8..796c7274a7 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,9 @@
*SVN*
+* Ensure that mysql quotes table names with database names correctly. Closes #9911 [crayz]
+
+ "foo.bar" => "`foo`.`bar`"
+
* Complete the assimilation of Sexy Migrations from ErrFree [Chris Wanstrath, PJ Hyett]
http://errtheblog.com/post/2381
diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
index 6ef7bb5b1a..65faa80065 100755
--- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -209,7 +209,7 @@ module ActiveRecord
end
def quote_table_name(name) #:nodoc:
- quote_column_name(name)
+ quote_column_name(name).gsub('.', '`.`')
end
def quote_string(string) #:nodoc:
diff --git a/activerecord/test/active_schema_test_mysql.rb b/activerecord/test/active_schema_test_mysql.rb
index aa1d712409..673c86c7ce 100644
--- a/activerecord/test/active_schema_test_mysql.rb
+++ b/activerecord/test/active_schema_test_mysql.rb
@@ -32,6 +32,10 @@ class ActiveSchemaTest < Test::Unit::TestCase
assert_equal "ALTER TABLE `people` ADD `key` varchar(32)", add_column(:people, :key, :string, :limit => 32)
end
+ def test_drop_table_with_specific_database
+ assert_equal "DROP TABLE `otherdb`.`people`", drop_table('otherdb.people')
+ end
+
private
def method_missing(method_symbol, *arguments)
ActiveRecord::Base.connection.send(method_symbol, *arguments)