Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

Conflicts:

	activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb

Conflicts:

	activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
	activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb

Conflicts:

	activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
	activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
	activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb
	activerecord/test/cases/adapters/mysql2/schema_test.rb
  • Loading branch information...
commit 6c0c40be4b6690d954aa91b4e2afb298d0e4f12c 1 parent b2feff2
@kennyj kennyj authored tenderlove committed
View
8 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -403,9 +403,11 @@ def collation
end
def tables(name = nil, database = nil) #:nodoc:
- tables = []
- result = execute(["SHOW TABLES", database].compact.join(' IN '), name)
- result.each { |field| tables << field[0] }
+ sql = "SHOW TABLES "
+ sql << "IN #{quote_table_name(database)} " if database
+
+ result = execute(sql, 'SCHEMA')
+ tables = result.collect { |field| field[0] }
result.free
tables
end
View
10 activerecord/test/cases/adapters/mysql/schema_test.rb
@@ -19,6 +19,16 @@ def self.name; 'Post'; end
end
end
+ def test_tables_quoting
+ begin
+ @connection.tables(nil, "foo-bar")
+ flunk
+ rescue => e
+ # assertion for *quoted* database properly
+ assert_match(/database 'foo-bar'/, e.inspect)
+ end
+ end
+
def test_schema
assert @omgpost.find(:first)
end

1 comment on commit 6c0c40b

@arunagw
Collaborator

This commit broke the build here http://travis-ci.org/#!/rails/rails/builds/1596517

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