Skip to content

Commit 8c1024b

Browse files
committed
Remove some more old version checks
1 parent 6317303 commit 8c1024b

File tree

6 files changed

+10
-91
lines changed

6 files changed

+10
-91
lines changed

lib/arjdbc/jdbc.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
require 'active_support/deprecation'
22

33
module ArJdbc
4-
5-
# @private
6-
AR42 = ::ActiveRecord::VERSION::STRING >= '4.2'
7-
8-
# @private
9-
AR52 = ::ActiveRecord::VERSION::STRING >= '5.2'
10-
114
class << self
125

136
# @private Internal API

lib/arjdbc/jdbc/column.rb

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,6 @@ def initialize(config, name, *args)
2828
end
2929
end
3030

31-
if ArJdbc::AR52
32-
# undefined method `cast' for #<ActiveRecord::ConnectionAdapters::SqlTypeMetadata> on AR52
33-
else
34-
default = args[0].cast(default)
35-
36-
sql_type = args.delete_at(1)
37-
type = args.delete_at(0)
38-
39-
args.unshift(SqlTypeMetadata.new(:sql_type => sql_type, :type => type))
40-
end
41-
42-
# super <= 4.1: (name, default, sql_type = nil, null = true)
43-
# super >= 4.2: (name, default, cast_type, sql_type = nil, null = true)
44-
# super >= 5.0: (name, default, sql_type_metadata = nil, null = true)
45-
4631
super(name, default, *args)
4732
init_column(name, default, *args)
4833
end
@@ -80,18 +65,8 @@ def self.column_types
8065
end
8166

8267
class << self
83-
84-
include Jdbc::TypeCast if ::ActiveRecord::VERSION::STRING >= '4.2'
85-
86-
if ActiveRecord::VERSION::MAJOR > 3 && ActiveRecord::VERSION::STRING < '4.2'
87-
88-
# @private provides compatibility between AR 3.x/4.0 API
89-
def string_to_date(value); value_to_date(value) end
90-
91-
end
92-
68+
include Jdbc::TypeCast
9369
end
94-
9570
end
9671
end
9772
end

lib/arjdbc/oracle/adapter.rb

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def add_index(table_name, column_name, options = {})
285285
execute "ALTER TABLE #{quote_table_name(table_name)} ADD CONSTRAINT #{quote_column_name(index_name)} #{index_type} (#{quoted_column_names})"
286286
end
287287
end
288-
end if AR42
288+
end
289289

290290
# @private
291291
def add_index_options(table_name, column_name, options = {})
@@ -309,7 +309,7 @@ def add_index_options(table_name, column_name, options = {})
309309

310310
quoted_column_names = column_names.map { |e| quote_column_name_or_expression(e) }.join(", ")
311311
[ index_name, index_type, quoted_column_names, tablespace, index_options ]
312-
end if AR42
312+
end
313313

314314
# @override
315315
def remove_index(table_name, options = {})
@@ -327,12 +327,7 @@ def remove_index(table_name, options = {})
327327
end
328328
execute "ALTER TABLE #{quote_table_name(table_name)} DROP CONSTRAINT #{quote_column_name(index_name)}" rescue nil
329329
execute "DROP INDEX #{quote_column_name(index_name)}"
330-
end if AR42
331-
332-
# @private
333-
def remove_index(table_name, options = {})
334-
execute "DROP INDEX #{index_name(table_name, options)}"
335-
end unless AR42
330+
end
336331

337332
def change_column_default(table_name, column_name, default)
338333
execute "ALTER TABLE #{quote_table_name(table_name)} MODIFY #{quote_column_name(column_name)} DEFAULT #{quote(default)}"
@@ -361,25 +356,11 @@ def rename_column(table_name, column_name, new_column_name)
361356
"RENAME COLUMN #{quote_column_name(column_name)} TO #{quote_column_name(new_column_name)}"
362357
end
363358

364-
if ActiveRecord::VERSION::MAJOR >= 4
365-
366359
# @override
367360
def remove_column(table_name, column_name, type = nil, options = {})
368361
do_remove_column(table_name, column_name)
369362
end
370363

371-
else
372-
373-
# @override
374-
def remove_column(table_name, *column_names)
375-
for column_name in column_names.flatten
376-
do_remove_column(table_name, column_name)
377-
end
378-
end
379-
alias remove_columns remove_column
380-
381-
end
382-
383364
def do_remove_column(table_name, column_name)
384365
execute "ALTER TABLE #{quote_table_name(table_name)} DROP COLUMN #{quote_column_name(column_name)}"
385366
end

lib/arjdbc/util/serialized_attributes.rb

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,11 @@ def dump_column_value(column)
3131
SerializedAttributes.dump_column_value(self, column)
3232
end
3333

34-
if defined? ActiveRecord::Type::Serialized # ArJdbc::AR42
35-
3634
def self.dump_column_value(record, column)
3735
value = record[ column.name.to_s ]
3836
column.cast_type.type_cast_for_database(value)
3937
end
4038

41-
else
42-
43-
def self.dump_column_value(record, column)
44-
value = record[ name = column.name.to_s ]
45-
if record.class.respond_to?(:serialized_attributes)
46-
if coder = record.class.serialized_attributes[name]
47-
value = coder.respond_to?(:dump) ? coder.dump(value) : value.to_yaml
48-
end
49-
else
50-
if record.respond_to?(:unserializable_attribute?)
51-
value = value.to_yaml if record.unserializable_attribute?(name, column)
52-
else
53-
value = value.to_yaml if value.is_a?(Hash)
54-
end
55-
end
56-
value
57-
end
58-
59-
end
60-
6139
def self.setup(lob_type = nil, after_save_alias = nil)
6240
ActiveRecord::Base.send :include, self # include SerializedAttributes
6341
ActiveRecord::Base.lob_type = lob_type unless lob_type.nil?

test/db/h2/offset_test.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,14 @@ def test_offset
4343
assert_equal ['Jack', 'James', 'Jason'], query.limit(3).map(&:firstname)
4444
assert_equal ['Joe', 'Johanna', 'John'], query.offset(8).map(&:firstname)
4545
assert_equal ['Joe', 'Johanna'], query.offset(8).limit(2).map(&:firstname)
46-
end if ar_version('3.0')
46+
end
4747

4848
def test_offset_arel
4949
query = Arel::Table.new(:persons).skip(3)
5050
assert_nothing_raised do
5151
sql = query.to_sql
52-
if ArJdbc::AR42
53-
assert_equal 'SELECT FROM persons LIMIT -1 OFFSET 3', sql, 'SQL statement was not generated, properly'
54-
else
55-
assert_equal "SELECT LIMIT 3", sql[0..13], "SQL statement was not generated, properly"
56-
end
52+
assert_equal 'SELECT FROM persons LIMIT -1 OFFSET 3', sql, 'SQL statement was not generated, properly'
5753
end
58-
end if ar_version('3.0')
54+
end
5955

6056
end

test/db/hsqldb/offset_test.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,14 @@ def test_offset
4343
assert_equal ['Jack', 'James', 'Jason'], query.limit(3).map(&:firstname)
4444
assert_equal ['Joe', 'Johanna', 'John'], query.offset(8).map(&:firstname)
4545
assert_equal ['Joe', 'Johanna'], query.offset(8).limit(2).map(&:firstname)
46-
end if ar_version('3.0')
46+
end
4747

4848
def test_offset_arel
4949
query = Arel::Table.new(:persons).skip(3)
5050
assert_nothing_raised do
5151
sql = query.to_sql
52-
if ArJdbc::AR42
53-
assert_equal 'SELECT FROM persons LIMIT 0 OFFSET 3', sql, 'SQL statement was not generated, properly'
54-
else
55-
assert_equal "SELECT LIMIT 3", sql[0..13], "SQL statement was not generated, properly"
56-
end
52+
assert_equal 'SELECT FROM persons LIMIT 0 OFFSET 3', sql, 'SQL statement was not generated, properly'
5753
end
58-
end if ar_version('3.0')
54+
end
5955

6056
end

0 commit comments

Comments
 (0)