Skip to content

Instantly share code, notes, and snippets.

@methodmissing
Created August 27, 2008 00:00
Show Gist options
  • Save methodmissing/7378 to your computer and use it in GitHub Desktop.
Save methodmissing/7378 to your computer and use it in GitHub Desktop.
ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do
def execute(sql, name = nil) #:nodoc:
if @connection.respond_to?(:async_query)
log(sql, "Async #{name || ''}") { @connection.async_query(sql) }
else
log(sql, name) { @connection.query(sql) }
end
rescue ActiveRecord::StatementInvalid => exception
if exception.message.split(":").first =~ /Packets out of order/
raise ActiveRecord::StatementInvalid, "'Packets out of order' error was received from the database. Please update your mysql bindings (gem install mysql) and read http://dev.mysql.com/doc/mysql/en/password-hashing.html for more information. If you're on Windows, use the Instant Rails installer to get the updated mysql bindings."
else
raise
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment