Skip to content

Commit 67f7d6f

Browse files
committed
introduce a AR40 helper constant for MySQL's adapter code
1 parent f1cf040 commit 67f7d6f

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

lib/arjdbc/mysql/adapter.rb

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ module ArJdbc
77
module MySQL
88

99
# @private
10-
AR42 = ActiveRecord::VERSION::STRING >= '4.2'
10+
AR40 = ::ActiveRecord::VERSION::MAJOR > 3
11+
# @private
12+
AR42 = ::ActiveRecord::VERSION::STRING >= '4.2'
1113

1214
require 'arjdbc/mysql/column'
1315
require 'arjdbc/mysql/bulk_change_table'
@@ -77,10 +79,10 @@ def configure_connection
7779
execute("SET #{encoding} #{variable_assignments}", :skip_logging)
7880
end
7981

80-
def strict_mode? # strict_mode is default since AR 4.0
82+
def strict_mode?
8183
config.key?(:strict) ?
8284
self.class.type_cast_config_to_boolean(config[:strict]) :
83-
::ActiveRecord::VERSION::MAJOR > 3
85+
AR40 # strict_mode is default since AR 4.0
8486
end
8587

8688
# @private
@@ -166,7 +168,7 @@ def initialize_schema_migrations_table
166168
else
167169
ActiveRecord::SchemaMigration.create_table
168170
end
169-
end if ::ActiveRecord::VERSION::MAJOR > 3
171+
end if AR40
170172

171173
# HELPER METHODS ===========================================
172174

@@ -340,12 +342,8 @@ def pk_and_sequence_for(table)
340342
# @private
341343
IndexDefinition = ::ActiveRecord::ConnectionAdapters::IndexDefinition
342344

343-
if ::ActiveRecord::VERSION::MAJOR > 3
344-
345-
INDEX_TYPES = [ :fulltext, :spatial ]
346-
INDEX_USINGS = [ :btree, :hash ]
347-
348-
end
345+
INDEX_TYPES = [ :fulltext, :spatial ] if AR40
346+
INDEX_USINGS = [ :btree, :hash ] if AR40
349347

350348
# Returns an array of indexes for the given table.
351349
# @override

0 commit comments

Comments
 (0)