Skip to content

Commit

Permalink
TECH-4739: Clean up mysql and mysql column adapter checks
Browse files Browse the repository at this point in the history
  • Loading branch information
dcaddell committed Sep 11, 2020
1 parent c6eba7c commit 9960faa
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/active_record/mysql/enum/enum_column_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Mysql
module Enum

class << self
def current_mysql_column_adapter
def mysql_column_adapter
if defined? ActiveRecord::ConnectionAdapters::Mysql2Adapter::Column
ActiveRecord::ConnectionAdapters::Mysql2Adapter::Column
elsif defined? ActiveRecord::ConnectionAdapters::MySQL::Column
Expand All @@ -19,7 +19,7 @@ def current_mysql_column_adapter
end
end

ActiveRecordColumnWithEnums = Enum.current_mysql_column_adapter
ActiveRecordColumnWithEnums = Enum.mysql_column_adapter

module EnumColumnAdapter
def initialize(*)
Expand Down
12 changes: 5 additions & 7 deletions lib/active_record/mysql/enum/mysql_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ module Mysql
module Enum

class << self
def current_mysql_adapter
if defined? ActiveRecord::ConnectionAdapters::Mysql2Adapter
ActiveRecord::ConnectionAdapters::Mysql2Adapter
else
raise "Could not find MySQL connection adapter"
end
def mysql_adapter
defined? ActiveRecord::ConnectionAdapters::Mysql2Adapter or raise "Could not find MySQL connection adapter"

ActiveRecord::ConnectionAdapters::Mysql2Adapter
end
end

ActiveRecordMysqlAdapter = Enum.current_mysql_adapter
ActiveRecordMysqlAdapter = Enum.mysql_adapter

module MysqlAdapter
def native_database_types #:nodoc
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/enum_column_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
end

it "raises" do
expect { ActiveRecord::Mysql::Enum.current_mysql_column_adapter }.to raise_error(RuntimeError, "could not find MySQL::Column or equivalent connection adapter")
expect { ActiveRecord::Mysql::Enum.mysql_column_adapter }.to raise_error(RuntimeError, "could not find MySQL::Column or equivalent connection adapter")
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/mysql_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
end

it "raises" do
expect { ActiveRecord::Mysql::Enum.current_mysql_adapter }.to raise_error(RuntimeError, "Could not find MySQL connection adapter")
expect { ActiveRecord::Mysql::Enum.mysql_adapter }.to raise_error(RuntimeError, "Could not find MySQL connection adapter")
end
end

Expand Down

0 comments on commit 9960faa

Please sign in to comment.