Skip to content

Commit

Permalink
Ensure that mysql quotes table names with database names correctly. C…
Browse files Browse the repository at this point in the history
…loses #9911 [crayz]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7980 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
technoweenie committed Oct 20, 2007
1 parent c9fecf2 commit 7042163
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions activerecord/CHANGELOG
@@ -1,5 +1,9 @@
*SVN* *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] * Complete the assimilation of Sexy Migrations from ErrFree [Chris Wanstrath, PJ Hyett]
http://errtheblog.com/post/2381 http://errtheblog.com/post/2381


Expand Down
Expand Up @@ -209,7 +209,7 @@ def quote_column_name(name) #:nodoc:
end end


def quote_table_name(name) #:nodoc: def quote_table_name(name) #:nodoc:
quote_column_name(name) quote_column_name(name).gsub('.', '`.`')
end end


def quote_string(string) #:nodoc: def quote_string(string) #:nodoc:
Expand Down
4 changes: 4 additions & 0 deletions activerecord/test/active_schema_test_mysql.rb
Expand Up @@ -32,6 +32,10 @@ def test_add_column_with_limit
assert_equal "ALTER TABLE `people` ADD `key` varchar(32)", add_column(:people, :key, :string, :limit => 32) assert_equal "ALTER TABLE `people` ADD `key` varchar(32)", add_column(:people, :key, :string, :limit => 32)
end end


def test_drop_table_with_specific_database
assert_equal "DROP TABLE `otherdb`.`people`", drop_table('otherdb.people')
end

private private
def method_missing(method_symbol, *arguments) def method_missing(method_symbol, *arguments)
ActiveRecord::Base.connection.send(method_symbol, *arguments) ActiveRecord::Base.connection.send(method_symbol, *arguments)
Expand Down

0 comments on commit 7042163

Please sign in to comment.