From f6332c576f52be9f9e6a970e8630a4ad9e3ed39e Mon Sep 17 00:00:00 2001 From: Jonathan Bender Date: Wed, 20 Feb 2019 11:02:24 -0800 Subject: [PATCH] Rails 5.2 removed BindVisitor --- lib/active_record/connection_adapters/odbc_adapter.rb | 7 ++++--- lib/odbc_adapter/adapters/mysql_odbc_adapter.rb | 3 ++- lib/odbc_adapter/adapters/null_odbc_adapter.rb | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/active_record/connection_adapters/odbc_adapter.rb b/lib/active_record/connection_adapters/odbc_adapter.rb index 672c5db1..dacd0854 100644 --- a/lib/active_record/connection_adapters/odbc_adapter.rb +++ b/lib/active_record/connection_adapters/odbc_adapter.rb @@ -1,5 +1,6 @@ require 'active_record' -require 'arel/visitors/bind_visitor' +# BindVisitor was removed in Arel 9 aka Rails 5.2 +require 'arel/visitors/bind_visitor' if Arel::VERSION.to_i < 9 require 'odbc' require 'odbc_adapter/database_limits' @@ -172,9 +173,9 @@ def translate_exception(exception, message) error_number = exception.message[/^\d+/].to_i if error_number == ERR_DUPLICATE_KEY_VALUE - ActiveRecord::RecordNotUnique.new(message, exception) + ActiveRecord::RecordNotUnique.new(message) elsif error_number == ERR_QUERY_TIMED_OUT || exception.message =~ ERR_QUERY_TIMED_OUT_MESSAGE - ::ODBCAdapter::QueryTimeoutError.new(message, exception) + ::ODBCAdapter::QueryTimeoutError.new(message) else super end diff --git a/lib/odbc_adapter/adapters/mysql_odbc_adapter.rb b/lib/odbc_adapter/adapters/mysql_odbc_adapter.rb index eaa690ef..0ff081e1 100644 --- a/lib/odbc_adapter/adapters/mysql_odbc_adapter.rb +++ b/lib/odbc_adapter/adapters/mysql_odbc_adapter.rb @@ -6,7 +6,8 @@ class MySQLODBCAdapter < ActiveRecord::ConnectionAdapters::ODBCAdapter PRIMARY_KEY = 'INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY'.freeze class BindSubstitution < Arel::Visitors::MySQL - include Arel::Visitors::BindVisitor + # BindVisitor was removed in Arel 9 aka Rails 5.2 + include Arel::Visitors::BindVisitor if Arel::VERSION.to_i < 9 end def arel_visitor diff --git a/lib/odbc_adapter/adapters/null_odbc_adapter.rb b/lib/odbc_adapter/adapters/null_odbc_adapter.rb index 1a179905..04eab19c 100644 --- a/lib/odbc_adapter/adapters/null_odbc_adapter.rb +++ b/lib/odbc_adapter/adapters/null_odbc_adapter.rb @@ -5,7 +5,8 @@ module Adapters # have an explicit adapter. class NullODBCAdapter < ActiveRecord::ConnectionAdapters::ODBCAdapter class BindSubstitution < Arel::Visitors::ToSql - include Arel::Visitors::BindVisitor + # BindVisitor was removed in Arel 9, or Rails 5.2 + include Arel::Visitors::BindVisitor if Arel::VERSION.to_i < 9 end # Using a BindVisitor so that the SQL string gets substituted before it is