Permalink
Browse files

No longer require database name for MySQL to allow cross database sel…

…ects.

[#1122 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
1 parent 202b091 commit 1af9bd58a04d14dc727713d2e581fafebc0e1d96 @tristandunn tristandunn committed with jeremy Aug 9, 2009
@@ -53,12 +53,7 @@ def self.mysql_connection(config) # :nodoc:
socket = config[:socket]
username = config[:username] ? config[:username].to_s : 'root'
password = config[:password].to_s
-
- if config.has_key?(:database)
- database = config[:database]
- else
- raise ArgumentError, "No database specified. Missing argument: database."
- end
+ database = config[:database]
# Require the MySQL driver and define Mysql::Result.all_hashes
unless defined? Mysql
@@ -63,6 +63,18 @@ def test_collation
def test_show_nonexistent_variable_returns_nil
assert_nil @connection.show_variable('foo_bar_baz')
end
+
+ def test_not_specifying_database_name_for_cross_database_selects
+ assert_nothing_raised do
+ ActiveRecord::Base.establish_connection({
+ :adapter => 'mysql',
+ :username => 'rails'
+ })
+ ActiveRecord::Base.connection.execute "SELECT activerecord_unittest.pirates.*, activerecord_unittest2.courses.* FROM activerecord_unittest.pirates, activerecord_unittest2.courses"
+ end
+
+ ActiveRecord::Base.establish_connection 'arunit'
+ end
end
if current_adapter?(:PostgreSQLAdapter)

0 comments on commit 1af9bd5

Please sign in to comment.