Skip to content

Commit de7bf12

Browse files
committed
Remove support for SQLServerAdapter, OracleAdapter and JBDC adapters in tests
As of rails/rails@8eae753 we are no longer supporting these and do not need to test them.
1 parent 0be846c commit de7bf12

29 files changed

+157
-390
lines changed

activerecord/Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ namespace :db do
5656
task drop: ["db:mysql:drop", "db:postgresql:drop"]
5757
end
5858

59-
%w( mysql2 trilogy postgresql sqlite3 sqlite3_mem oracle jdbcmysql jdbcpostgresql jdbcsqlite3 jdbcderby jdbch2 jdbchsqldb ).each do |adapter|
59+
%w( mysql2 trilogy postgresql sqlite3 sqlite3_mem ).each do |adapter|
6060
namespace :test do
6161
Rake::TestTask.new(adapter => "#{adapter}:env") do |t|
6262
adapter_short = adapter[/^[a-z0-9]+/]

activerecord/test/cases/associations/belongs_to_associations_test.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ def test_belongs_to_with_primary_key_joins_on_correct_column
103103
if current_adapter?(:Mysql2Adapter, :TrilogyAdapter)
104104
assert_no_match(/`firm_with_primary_keys_companies`\.`id`/, sql)
105105
assert_match(/`firm_with_primary_keys_companies`\.`name`/, sql)
106-
elsif current_adapter?(:OracleAdapter)
107-
# on Oracle aliases are truncated to 30 characters and are quoted in uppercase
108-
assert_no_match(/"firm_with_primary_keys_compani"\."id"/i, sql)
109-
assert_match(/"firm_with_primary_keys_compani"\."name"/i, sql)
110106
else
111107
assert_no_match(/"firm_with_primary_keys_companies"\."id"/, sql)
112108
assert_match(/"firm_with_primary_keys_companies"\."name"/, sql)

activerecord/test/cases/attribute_methods_test.rb

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -692,23 +692,13 @@ def topic.approved; false; end
692692

693693
test "typecast attribute from select to false" do
694694
Topic.create(title: "Budget")
695-
# Oracle does not support boolean expressions in SELECT.
696-
if current_adapter?(:OracleAdapter)
697-
topic = Topic.all.merge!(select: "topics.*, 0 as is_test").first
698-
else
699-
topic = Topic.all.merge!(select: "topics.*, 1=2 as is_test").first
700-
end
695+
topic = Topic.all.merge!(select: "topics.*, 1=2 as is_test").first
701696
assert_not_predicate topic, :is_test?
702697
end
703698

704699
test "typecast attribute from select to true" do
705700
Topic.create(title: "Budget")
706-
# Oracle does not support boolean expressions in SELECT.
707-
if current_adapter?(:OracleAdapter)
708-
topic = Topic.all.merge!(select: "topics.*, 1 as is_test").first
709-
else
710-
topic = Topic.all.merge!(select: "topics.*, 2=2 as is_test").first
711-
end
701+
topic = Topic.all.merge!(select: "topics.*, 2=2 as is_test").first
712702
assert_predicate topic, :is_test?
713703
end
714704

activerecord/test/cases/autosave_association_test.rb

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,12 +1543,7 @@ def test_should_still_allow_to_bypass_validations_on_the_associated_model
15431543
@pirate.catchphrase = ""
15441544
@pirate.ship.name = ""
15451545
@pirate.save(validate: false)
1546-
# Oracle saves empty string as NULL
1547-
if current_adapter?(:OracleAdapter)
1548-
assert_equal [nil, nil], [@pirate.reload.catchphrase, @pirate.ship.name]
1549-
else
1550-
assert_equal ["", ""], [@pirate.reload.catchphrase, @pirate.ship.name]
1551-
end
1546+
assert_equal ["", ""], [@pirate.reload.catchphrase, @pirate.ship.name]
15521547
end
15531548

15541549
def test_should_allow_to_bypass_validations_on_associated_models_at_any_depth
@@ -1560,12 +1555,7 @@ def test_should_allow_to_bypass_validations_on_associated_models_at_any_depth
15601555
@pirate.save(validate: false)
15611556

15621557
values = [@pirate.reload.catchphrase, @pirate.ship.name, *@pirate.ship.parts.map(&:name)]
1563-
# Oracle saves empty string as NULL
1564-
if current_adapter?(:OracleAdapter)
1565-
assert_equal [nil, nil, nil, nil], values
1566-
else
1567-
assert_equal ["", "", "", ""], values
1568-
end
1558+
assert_equal ["", "", "", ""], values
15691559
end
15701560

15711561
def test_should_still_raise_an_ActiveRecordRecord_Invalid_exception_if_we_want_that
@@ -1732,12 +1722,7 @@ def test_should_still_allow_to_bypass_validations_on_the_associated_model
17321722
@ship.pirate.catchphrase = ""
17331723
@ship.name = ""
17341724
@ship.save(validate: false)
1735-
# Oracle saves empty string as NULL
1736-
if current_adapter?(:OracleAdapter)
1737-
assert_equal [nil, nil], [@ship.reload.name, @ship.pirate.catchphrase]
1738-
else
1739-
assert_equal ["", ""], [@ship.reload.name, @ship.pirate.catchphrase]
1740-
end
1725+
assert_equal ["", ""], [@ship.reload.name, @ship.pirate.catchphrase]
17411726
end
17421727

17431728
def test_should_still_raise_an_ActiveRecordRecord_Invalid_exception_if_we_want_that
@@ -1869,20 +1854,11 @@ def test_should_allow_to_bypass_validations_on_the_associated_models_on_update
18691854
@pirate.public_send(@association_name).each { |child| child.name = "" }
18701855

18711856
assert @pirate.save(validate: false)
1872-
# Oracle saves empty string as NULL
1873-
if current_adapter?(:OracleAdapter)
1874-
assert_equal [nil, nil, nil], [
1875-
@pirate.reload.catchphrase,
1876-
@pirate.public_send(@association_name).first.name,
1877-
@pirate.public_send(@association_name).last.name
1878-
]
1879-
else
1880-
assert_equal ["", "", ""], [
1881-
@pirate.reload.catchphrase,
1882-
@pirate.public_send(@association_name).first.name,
1883-
@pirate.public_send(@association_name).last.name
1884-
]
1885-
end
1857+
assert_equal ["", "", ""], [
1858+
@pirate.reload.catchphrase,
1859+
@pirate.public_send(@association_name).first.name,
1860+
@pirate.public_send(@association_name).last.name
1861+
]
18861862
end
18871863

18881864
def test_should_validation_the_associated_models_on_create

activerecord/test/cases/base_test.rb

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,7 @@ def test_column_names_are_escaped
151151
}
152152

153153
quoted = conn.quote_column_name "foo#{badchar}bar"
154-
if current_adapter?(:OracleAdapter)
155-
# Oracle does not allow double quotes in table and column names at all
156-
# therefore quoting removes them
157-
assert_equal("#{badchar}foobar#{badchar}", quoted)
158-
else
159-
assert_equal("#{badchar}foo#{badchar * 2}bar#{badchar}", quoted)
160-
end
154+
assert_equal("#{badchar}foo#{badchar * 2}bar#{badchar}", quoted)
161155
end
162156

163157
def test_columns_should_obey_set_primary_key
@@ -545,39 +539,27 @@ def test_default_values
545539
topic = Topic.find(topic.id)
546540
assert_predicate topic, :approved?
547541
assert_nil topic.last_read
548-
549-
# Oracle has some funky default handling, so it requires a bit of
550-
# extra testing. See ticket #2788.
551-
if current_adapter?(:OracleAdapter)
552-
test = TestOracleDefault.new
553-
assert_equal "X", test.test_char
554-
assert_equal "hello", test.test_string
555-
assert_equal 3, test.test_int
556-
end
557542
end
558543

559-
# Oracle does not have a TIME datatype.
560-
unless current_adapter?(:OracleAdapter)
561-
def test_utc_as_time_zone
562-
with_timezone_config default: :utc do
563-
attributes = { "bonus_time" => "5:42:00AM" }
564-
topic = Topic.find(1)
565-
topic.attributes = attributes
566-
assert_equal Time.utc(2000, 1, 1, 5, 42, 0), topic.bonus_time
567-
end
544+
def test_utc_as_time_zone
545+
with_timezone_config default: :utc do
546+
attributes = { "bonus_time" => "5:42:00AM" }
547+
topic = Topic.find(1)
548+
topic.attributes = attributes
549+
assert_equal Time.utc(2000, 1, 1, 5, 42, 0), topic.bonus_time
568550
end
551+
end
569552

570-
def test_utc_as_time_zone_and_new
571-
with_timezone_config default: :utc do
572-
attributes = { "bonus_time(1i)" => "2000",
573-
"bonus_time(2i)" => "1",
574-
"bonus_time(3i)" => "1",
575-
"bonus_time(4i)" => "10",
576-
"bonus_time(5i)" => "35",
577-
"bonus_time(6i)" => "50" }
578-
topic = Topic.new(attributes)
579-
assert_equal Time.utc(2000, 1, 1, 10, 35, 50), topic.bonus_time
580-
end
553+
def test_utc_as_time_zone_and_new
554+
with_timezone_config default: :utc do
555+
attributes = { "bonus_time(1i)" => "2000",
556+
"bonus_time(2i)" => "1",
557+
"bonus_time(3i)" => "1",
558+
"bonus_time(4i)" => "10",
559+
"bonus_time(5i)" => "35",
560+
"bonus_time(6i)" => "50" }
561+
topic = Topic.new(attributes)
562+
assert_equal Time.utc(2000, 1, 1, 10, 35, 50), topic.bonus_time
581563
end
582564
end
583565

@@ -922,9 +904,6 @@ def test_group_weirds_by_from
922904
end
923905

924906
def test_attributes_on_dummy_time
925-
# Oracle does not have a TIME datatype.
926-
return true if current_adapter?(:OracleAdapter)
927-
928907
with_timezone_config default: :local do
929908
attributes = {
930909
"bonus_time" => "5:42:00AM"
@@ -939,9 +918,6 @@ def test_attributes_on_dummy_time
939918
end
940919

941920
def test_attributes_on_dummy_time_with_invalid_time
942-
# Oracle does not have a TIME datatype.
943-
return true if current_adapter?(:OracleAdapter)
944-
945921
attributes = {
946922
"bonus_time" => "not a time"
947923
}

activerecord/test/cases/calculations_test.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -277,24 +277,18 @@ def test_count_should_shortcut_with_limit_zero
277277
end
278278

279279
def test_limit_is_kept
280-
return if current_adapter?(:OracleAdapter)
281-
282280
queries = capture_sql { Account.limit(1).count }
283281
assert_equal 1, queries.length
284282
assert_match(/LIMIT/, queries.first)
285283
end
286284

287285
def test_offset_is_kept
288-
return if current_adapter?(:OracleAdapter)
289-
290286
queries = capture_sql { Account.offset(1).count }
291287
assert_equal 1, queries.length
292288
assert_match(/OFFSET/, queries.first)
293289
end
294290

295291
def test_limit_with_offset_is_kept
296-
return if current_adapter?(:OracleAdapter)
297-
298292
queries = capture_sql { Account.limit(1).offset(1).count }
299293
assert_equal 1, queries.length
300294
assert_match(/LIMIT/, queries.first)
@@ -844,11 +838,7 @@ def test_pluck_with_empty_in
844838
end
845839

846840
def test_pluck_without_column_names
847-
if current_adapter?(:OracleAdapter)
848-
assert_equal [[1, "Firm", 1, nil, "37signals", nil, 1, nil, nil, "active"]], Company.order(:id).limit(1).pluck
849-
else
850-
assert_equal [[1, "Firm", 1, nil, "37signals", nil, 1, nil, "", "active"]], Company.order(:id).limit(1).pluck
851-
end
841+
assert_equal [[1, "Firm", 1, nil, "37signals", nil, 1, nil, "", "active"]], Company.order(:id).limit(1).pluck
852842
end
853843

854844
def test_pluck_type_cast

activerecord/test/cases/comment_test.rb

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,9 @@ def test_add_column_with_comment_later
8787
end
8888

8989
def test_add_index_with_comment_later
90-
unless current_adapter?(:OracleAdapter)
91-
@connection.add_index :commenteds, :obvious, name: "idx_obvious", comment: "We need to see obvious comments"
92-
index = @connection.indexes("commenteds").find { |idef| idef.name == "idx_obvious" }
93-
assert_equal "We need to see obvious comments", index.comment
94-
end
90+
@connection.add_index :commenteds, :obvious, name: "idx_obvious", comment: "We need to see obvious comments"
91+
index = @connection.indexes("commenteds").find { |idef| idef.name == "idx_obvious" }
92+
assert_equal "We need to see obvious comments", index.comment
9593
end
9694

9795
def test_add_comment_to_column
@@ -139,13 +137,9 @@ def test_schema_dump_with_comments
139137
assert_match %r[t\.string\s+"name",\s+comment: "Comment should help clarify the column purpose"], output
140138
assert_match %r[t\.string\s+"obvious"\n], output
141139
assert_match %r[t\.string\s+"content",\s+comment: "Whoa, content describes itself!"], output
142-
if current_adapter?(:OracleAdapter)
143-
assert_match %r[t\.integer\s+"rating",\s+precision: 38,\s+comment: "I am running out of imagination"], output
144-
else
145-
assert_match %r[t\.integer\s+"rating",\s+comment: "I am running out of imagination"], output
146-
assert_match %r[t\.index\s+.+\s+comment: "\\"Very important\\" index that powers all the performance.\\nAnd it's fun!"], output
147-
assert_match %r[t\.index\s+.+\s+name: "idx_obvious",\s+comment: "We need to see obvious comments"], output
148-
end
140+
assert_match %r[t\.integer\s+"rating",\s+comment: "I am running out of imagination"], output
141+
assert_match %r[t\.index\s+.+\s+comment: "\\"Very important\\" index that powers all the performance.\\nAnd it's fun!"], output
142+
assert_match %r[t\.index\s+.+\s+name: "idx_obvious",\s+comment: "We need to see obvious comments"], output
149143
end
150144

151145
def test_schema_dump_omits_blank_comments

activerecord/test/cases/connection_adapters/type_lookup_test.rb

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,29 +83,17 @@ def test_integer_types
8383

8484
def test_bigint_limit
8585
limit = @connection.send(:type_map).lookup("bigint").send(:_limit)
86-
if current_adapter?(:OracleAdapter)
87-
assert_equal 19, limit
88-
else
89-
assert_equal 8, limit
90-
end
86+
87+
assert_equal 8, limit
9188
end
9289

9390
def test_decimal_without_scale
94-
if current_adapter?(:OracleAdapter)
95-
{
96-
decimal: %w{decimal(2) decimal(2,0) numeric(2) numeric(2,0)},
97-
integer: %w{number(2) number(2,0)}
98-
}
99-
else
100-
{ decimal: %w{decimal(2) decimal(2,0) numeric(2) numeric(2,0) number(2) number(2,0)} }
101-
end.each do |expected_type, types|
102-
types.each do |type|
91+
%w{decimal(2) decimal(2,0) numeric(2) numeric(2,0) number(2) number(2,0)}.each do |type|
10392
cast_type = @connection.send(:type_map).lookup(type)
10493

105-
assert_equal expected_type, cast_type.type
94+
assert_equal :decimal, cast_type.type
10695
assert_equal 2, cast_type.cast(2.1)
107-
end
108-
end
96+
end
10997
end
11098

11199
private

activerecord/test/cases/database_statements_test.rb

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ def setup
77
@connection = ActiveRecord::Base.lease_connection
88
end
99

10-
unless current_adapter?(:OracleAdapter)
11-
def test_exec_insert
12-
result = @connection.exec_insert("INSERT INTO accounts (firm_id,credit_limit) VALUES (42,5000)", nil, [])
13-
assert_not_nil @connection.send(:last_inserted_id, result)
14-
end
10+
def test_exec_insert
11+
result = @connection.exec_insert("INSERT INTO accounts (firm_id,credit_limit) VALUES (42,5000)", nil, [])
12+
assert_not_nil @connection.send(:last_inserted_id, result)
1513
end
1614

1715
def test_insert_should_return_the_inserted_id
@@ -24,13 +22,6 @@ def test_create_should_return_the_inserted_id
2422

2523
private
2624
def return_the_inserted_id(method:)
27-
# Oracle adapter uses prefetched primary key values from sequence and passes them to connection adapter insert method
28-
if current_adapter?(:OracleAdapter)
29-
sequence_name = "accounts_seq"
30-
id_value = @connection.next_sequence_value(sequence_name)
31-
@connection.send(method, "INSERT INTO accounts (id, firm_id,credit_limit) VALUES (accounts_seq.nextval,42,5000)", nil, :id, id_value, sequence_name)
32-
else
33-
@connection.send(method, "INSERT INTO accounts (firm_id,credit_limit) VALUES (42,5000)")
34-
end
25+
@connection.send(method, "INSERT INTO accounts (firm_id,credit_limit) VALUES (42,5000)")
3526
end
3627
end

activerecord/test/cases/date_time_precision_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def test_schema_dump_with_without_precision_has_precision_as_nil
245245
assert_match %r{t\.datetime\s+"updated_at",\s+precision: nil,\s+null: false$}, output
246246
end
247247

248-
if current_adapter?(:PostgreSQLAdapter, :SQLServerAdapter)
248+
if current_adapter?(:PostgreSQLAdapter)
249249
def test_datetime_precision_with_zero_should_be_dumped
250250
@connection.create_table(:foos, force: true) do |t|
251251
t.timestamps precision: 0

0 commit comments

Comments
 (0)