Permalink
Browse files

Fix GH #3163. Should quote database on mysql/mysql2.

Conflicts:

	activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb
  • Loading branch information...
kennyj authored and tenderlove committed Mar 3, 2012
1 parent 0391ae9 commit 22994b2d638738abce7dc7672c27a5e7171018e8
@@ -375,7 +375,7 @@ def collation
def tables(name = nil, database = nil, like = nil) #:nodoc:
sql = "SHOW TABLES "
sql << "IN #{database} " if database
sql << "IN #{quote_table_name(database)} " if database
sql << "LIKE #{quote(like)}" if like
execute_and_free(sql, 'SCHEMA') do |result|
@@ -82,6 +82,16 @@ def test_pk_and_sequence_for_with_custom_index_type_pk
assert_equal @conn.default_sequence_name('ex_with_custom_index_type_pk', 'id'), seq
end
def test_tables_quoting
begin
@conn.tables(nil, "foo-bar", nil)
flunk
rescue => e
# assertion for *quoted* database properly
assert_match(/Access denied for user/, e.inspect)
end
end
private
def insert(ctx, data)
binds = data.map { |name, value|
@@ -35,6 +35,17 @@ def test_table_exists?
def test_table_exists_wrong_schema
assert(!@connection.table_exists?("#{@db_name}.zomg"), "table should not exist")
end
def test_tables_quoting
begin
@connection.tables(nil, "foo-bar", nil)
flunk
rescue => e
# assertion for *quoted* database properly
assert_match(/Access denied for user/, e.inspect)
end
end
end
end
end

0 comments on commit 22994b2

Please sign in to comment.