Skip to content

Instantly share code, notes, and snippets.

@todesking
Created December 6, 2012 11:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todesking/4223757 to your computer and use it in GitHub Desktop.
Save todesking/4223757 to your computer and use it in GitHub Desktop.
# 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