Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Suppress annoy warning, when executing AR's testcases. #7432

merged 2 commits into from

4 participants


We always see the follwing warning, when executing rake test_mysql

...warning: instance variable errno not initialized...

I know we shouldn't hide warnings, but I guess that development for mysql gem is not active.

according to
and, we can't access this iv ?


This message is very annoying yeah, and I'm happy to merge it. I just thought that perhaps we should move it to our tests setup instead of the connection adapter, since it's a hack for our tests only, wdyt?


I agree with @carlosantoniodasilva on this. We should probably move to the test cases.


@carlosantoniodasilva @tenderlove I moved to the testcases.

BTW, I found the below comment in mysql_adapter

  8 class Mysql
  9   class Time
 10     ###
 11     # This monkey patch is for test_additional_columns_from_join_table
 12     def to_date
 13, month, day)
 14     end
 15   end

Should we move it to the testcases ?


@kennyj I don't think this code is used only in tests. I guess it is fixing some issue. But I'm just guessing


When I remove Mysql::Time#to_date, many testcases are failed, and I confirm some functionalities depend on the method. I'll remove this comment.


I added 48498da .

@rafaelfranca rafaelfranca merged commit 7b2363f into rails:master

Great! Thanks

@aderyabin aderyabin referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
2  activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -7,8 +7,6 @@
class Mysql
class Time
- ###
- # This monkey patch is for test_additional_columns_from_join_table
def to_date, month, day)
2  activerecord/test/cases/helper.rb
@@ -22,6 +22,8 @@
# Connect to the database
+require 'support/mysql'
# Quote "type" if it's a reserved word for the current connection.
QUOTED_TYPE = ActiveRecord::Base.connection.quote_column_name('type')
11 activerecord/test/support/mysql.rb
@@ -0,0 +1,11 @@
+if defined?(Mysql)
+ class Mysql
+ class Error
+ # This monkey patch fixes annoy warning with mysql-2.8.1.gem when executing testcases.
+ def errno_with_fix_warnings
+ silence_warnings { errno_without_fix_warnings }
+ end
+ alias_method_chain :errno, :fix_warnings
+ end
+ end
Something went wrong with that request. Please try again.