Created
December 6, 2012 11:13
-
-
Save todesking/4223757 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/environments/development.rb | |
# ActiveRecord 3.2.8 / mysql2 0.3.11 | |
Application.configure do | |
config.after_initialize do | |
class ActiveRecord::ConnectionAdapters::Mysql2Adapter | |
def execute_with_warning_is_error(sql, *rest) | |
result = execute_without_warning_is_error(sql, *rest) | |
warnings = execute_without_warning_is_error('show warnings', :skip_logging).to_a | |
unless warnings.empty? | |
raise "SQL実行中にwarning出ました!!!!! SQL: #{sql}, warnings: #{warnings.inspect}" | |
end | |
result | |
end | |
alias_method_chain :execute, :warning_is_error | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment