Skip to content

Commit

Permalink
No longer require database name for MySQL to allow cross database sel…
Browse files Browse the repository at this point in the history
…ects.

[#1122 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information
tristandunn authored and jeremy committed Aug 9, 2009
1 parent 202b091 commit 1af9bd5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions activerecord/test/cases/adapter_test.rb
Expand Up @@ -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)
Expand Down

0 comments on commit 1af9bd5

Please sign in to comment.