1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

MySQL: work around ruby-mysql/mysql-ruby inconsistency with mysql.stat. Eliminate usage of mysql.ping because it doesn't guarantee reconnect. Explicitly close and reopen the connection instead. References #428.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3216 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jeremy Kemper 2005-12-03 23:04:34 +00:00
parent 4f1e37ccd4
commit 6c9cfd64ca
2 changed files with 11 additions and 7 deletions

View file

@ -1,5 +1,7 @@
*SVN*
* MySQL: work around ruby-mysql/mysql-ruby inconsistency with mysql.stat. Eliminate usage of mysql.ping because it doesn't guarantee reconnect. Explicitly close and reopen the connection instead. [Jeremy Kemper]
* Added preliminary support for polymorphic associations [DHH]
* Added preliminary support for join models [DHH]

View file

@ -155,19 +155,21 @@ module ActiveRecord
else
@connection.query 'select 1'
end
# mysql-ruby doesn't raise an exception when stat fails.
if @connection.respond_to?(:errno)
@connection.errno.zero?
else
true
end
rescue Mysql::Error
false
end
def reconnect!
if @connection.respond_to?(:ping)
@connection.ping
else
@connection.close rescue nil
connect
end
end
# DATABASE STATEMENTS ======================================