Skip to content

Commit b3690da

Browse files
committed
use AR42_COMPAT constant for AR 4.2
1 parent cbd8fb1 commit b3690da

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

lib/arjdbc/postgresql/adapter.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ def type_cast(value, column, array_member = false)
242242
}) if AR4_COMPAT
243243

244244
NATIVE_DATABASE_TYPES.update(
245-
:bit => { name: "bit" },
246-
:bit_varying => { name: "bit varying" }
247-
) if ActiveRecord::VERSION.to_s >= '4.2'
245+
:bit => { :name => "bit" },
246+
:bit_varying => { :name => "bit varying" }
247+
) if AR42_COMPAT
248248

249249
def native_database_types
250250
NATIVE_DATABASE_TYPES
@@ -876,7 +876,7 @@ def quote(value, column = nil)
876876
else
877877
super
878878
end
879-
end if ActiveRecord::VERSION.to_s < '4.2'
879+
end unless AR42_COMPAT
880880

881881
def quote(value, column = nil)
882882
return super unless column
@@ -891,7 +891,7 @@ def quote(value, column = nil)
891891
else
892892
super
893893
end
894-
end if ActiveRecord::VERSION.to_s >= '4.2'
894+
end if AR42_COMPAT
895895

896896
# Quotes a string, escaping any ' (single quote) and \ (backslash) chars.
897897
# @return [String]
@@ -1025,7 +1025,7 @@ def add_column(table_name, column_name, type, options = {})
10251025

10261026
change_column_default(table_name, column_name, default) if options_include_default?(options)
10271027
change_column_null(table_name, column_name, false, default) if notnull
1028-
end if ActiveRecord::VERSION::MAJOR < 4
1028+
end if ::ActiveRecord::VERSION::MAJOR < 4
10291029

10301030
# Changes the column of a table.
10311031
def change_column(table_name, column_name, type, options = {})
@@ -1452,7 +1452,7 @@ def primary_key(name, type = :primary_key, options = {})
14521452
options[:default] = options.fetch(:default, 'uuid_generate_v4()')
14531453
options[:primary_key] = true
14541454
column name, type, options
1455-
end if ActiveRecord::VERSION::MAJOR > 3 # 3.2 super expects (name)
1455+
end if ::ActiveRecord::VERSION::MAJOR > 3 # 3.2 super expects (name)
14561456

14571457
def column(name, type = nil, options = {})
14581458
super
@@ -1466,7 +1466,7 @@ def column(name, type = nil, options = {})
14661466

14671467
private
14681468

1469-
if ActiveRecord::VERSION::MAJOR > 3
1469+
if ::ActiveRecord::VERSION::MAJOR > 3
14701470

14711471
def create_column_definition(name, type)
14721472
ColumnDefinition.new name, type
@@ -1495,7 +1495,7 @@ class Table < ActiveRecord::ConnectionAdapters::Table
14951495

14961496
def update_table_definition(table_name, base)
14971497
Table.new(table_name, base)
1498-
end if ActiveRecord::VERSION::MAJOR > 3
1498+
end if ::ActiveRecord::VERSION::MAJOR > 3
14991499

15001500
def jdbc_connection_class(spec)
15011501
::ArJdbc::PostgreSQL.jdbc_connection_class
@@ -1506,7 +1506,7 @@ def jdbc_column_class
15061506
::ActiveRecord::ConnectionAdapters::PostgreSQLColumn
15071507
end
15081508

1509-
if ActiveRecord::VERSION::MAJOR < 4 # Rails 3.x compatibility
1509+
if ::ActiveRecord::VERSION::MAJOR < 4 # Rails 3.x compatibility
15101510
PostgreSQLJdbcConnection.raw_array_type = true if PostgreSQLJdbcConnection.raw_array_type? == nil
15111511
PostgreSQLJdbcConnection.raw_hstore_type = true if PostgreSQLJdbcConnection.raw_hstore_type? == nil
15121512
end

lib/arjdbc/postgresql/oid_types.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module PostgreSQL
77
module OIDTypes
88

99
OID = ActiveRecord::ConnectionAdapters::PostgreSQL::OID
10-
Type = ActiveRecord::Type if ActiveRecord::VERSION.to_s >= '4.2'
10+
Type = ActiveRecord::Type if AR42_COMPAT
1111

1212
def get_oid_type(oid, fmod, column_name)
1313
type_map.fetch(oid, fmod) {

0 commit comments

Comments
 (0)