Skip to content

Commit

Permalink
Rails 5.2 removed BindVisitor
Browse files Browse the repository at this point in the history
  • Loading branch information
jbender committed Feb 20, 2019
1 parent f273df9 commit f6332c5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lib/active_record/connection_adapters/odbc_adapter.rb
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/odbc_adapter/adapters/mysql_odbc_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/odbc_adapter/adapters/null_odbc_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f6332c5

Please sign in to comment.