Skip to content

Commit 7359f81

Browse files
committed
Merge pull request rails#15137 from sgrif/sg-remove-dead-code
Remove dead test code for unsupported adapters
2 parents 0671315 + 8df8334 commit 7359f81

19 files changed

+82
-183
lines changed

activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb

-9
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,8 @@ def [](name)
123123
# Default is (38,0).
124124
# * DB2: <tt>:precision</tt> [1..63], <tt>:scale</tt> [0..62].
125125
# Default unknown.
126-
# * Firebird: <tt>:precision</tt> [1..18], <tt>:scale</tt> [0..18].
127-
# Default (9,0). Internal types NUMERIC and DECIMAL have different
128-
# storage rules, decimal being better.
129-
# * FrontBase?: <tt>:precision</tt> [1..38], <tt>:scale</tt> [0..38].
130-
# Default (38,0). WARNING Max <tt>:precision</tt>/<tt>:scale</tt> for
131-
# NUMERIC is 19, and DECIMAL is 38.
132126
# * SqlServer?: <tt>:precision</tt> [1..38], <tt>:scale</tt> [0..38].
133127
# Default (38,0).
134-
# * Sybase: <tt>:precision</tt> [1..38], <tt>:scale</tt> [0..38].
135-
# Default (38,0).
136-
# * OpenBase?: Documentation unclear. Claims storage in <tt>double</tt>.
137128
#
138129
# This method returns <tt>self</tt>.
139130
#

activerecord/lib/active_record/migration.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def initialize
195195
# == Database support
196196
#
197197
# Migrations are currently supported in MySQL, PostgreSQL, SQLite,
198-
# SQL Server, Sybase, and Oracle (all supported databases except DB2).
198+
# SQL Server, and Oracle (all supported databases except DB2).
199199
#
200200
# == More examples
201201
#

activerecord/lib/active_record/model_schema.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def reset_sequence_name #:nodoc:
198198
# given block. This is required for Oracle and is useful for any
199199
# database which relies on sequences for primary key generation.
200200
#
201-
# If a sequence name is not explicitly set when using Oracle or Firebird,
201+
# If a sequence name is not explicitly set when using Oracle,
202202
# it will default to the commonly used pattern of: #{table_name}_seq
203203
#
204204
# If a sequence name is not explicitly set when using PostgreSQL, it

activerecord/test/cases/adapter_test.rb

+9-13
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ def test_indexes
4646
@connection.add_index :accounts, :firm_id, :name => idx_name
4747
indexes = @connection.indexes("accounts")
4848
assert_equal "accounts", indexes.first.table
49-
# OpenBase does not have the concept of a named index
50-
# Indexes are merely properties of columns.
51-
assert_equal idx_name, indexes.first.name unless current_adapter?(:OpenBaseAdapter)
49+
assert_equal idx_name, indexes.first.name
5250
assert !indexes.first.unique
5351
assert_equal ["firm_id"], indexes.first.columns
5452
else
@@ -127,14 +125,12 @@ def test_reset_empty_table_with_custom_pk
127125
assert_equal 1, Movie.create(:name => 'fight club').id
128126
end
129127

130-
if ActiveRecord::Base.connection.adapter_name != "FrontBase"
131-
def test_reset_table_with_non_integer_pk
132-
Subscriber.delete_all
133-
Subscriber.connection.reset_pk_sequence! 'subscribers'
134-
sub = Subscriber.new(:name => 'robert drake')
135-
sub.id = 'bob drake'
136-
assert_nothing_raised { sub.save! }
137-
end
128+
def test_reset_table_with_non_integer_pk
129+
Subscriber.delete_all
130+
Subscriber.connection.reset_pk_sequence! 'subscribers'
131+
sub = Subscriber.new(:name => 'robert drake')
132+
sub.id = 'bob drake'
133+
assert_nothing_raised { sub.save! }
138134
end
139135
end
140136

@@ -144,7 +140,7 @@ def test_uniqueness_violations_are_translated_to_specific_exception
144140
@connection.execute "INSERT INTO subscribers(nick) VALUES('me')"
145141
end
146142
end
147-
143+
148144
unless current_adapter?(:SQLite3Adapter)
149145
def test_foreign_key_violations_are_translated_to_specific_exception
150146
assert_raises(ActiveRecord::InvalidForeignKey) do
@@ -157,7 +153,7 @@ def test_foreign_key_violations_are_translated_to_specific_exception
157153
end
158154
end
159155
end
160-
156+
161157
def test_foreign_key_violations_are_translated_to_specific_exception_with_validate_false
162158
klass_has_fk = Class.new(ActiveRecord::Base) do
163159
self.table_name = 'fk_test_has_fk'

activerecord/test/cases/associations/eager_test.rb

+3-17
Original file line numberDiff line numberDiff line change
@@ -534,21 +534,13 @@ def test_eager_with_has_many_and_limit
534534
end
535535

536536
def test_eager_with_has_many_and_limit_and_conditions
537-
if current_adapter?(:OpenBaseAdapter)
538-
posts = Post.all.merge!(:includes => [ :author, :comments ], :limit => 2, :where => "FETCHBLOB(posts.body) = 'hello'", :order => "posts.id").to_a
539-
else
540-
posts = Post.all.merge!(:includes => [ :author, :comments ], :limit => 2, :where => "posts.body = 'hello'", :order => "posts.id").to_a
541-
end
537+
posts = Post.all.merge!(:includes => [ :author, :comments ], :limit => 2, :where => "posts.body = 'hello'", :order => "posts.id").to_a
542538
assert_equal 2, posts.size
543539
assert_equal [4,5], posts.collect { |p| p.id }
544540
end
545541

546542
def test_eager_with_has_many_and_limit_and_conditions_array
547-
if current_adapter?(:OpenBaseAdapter)
548-
posts = Post.all.merge!(:includes => [ :author, :comments ], :limit => 2, :where => [ "FETCHBLOB(posts.body) = ?", 'hello' ], :order => "posts.id").to_a
549-
else
550-
posts = Post.all.merge!(:includes => [ :author, :comments ], :limit => 2, :where => [ "posts.body = ?", 'hello' ], :order => "posts.id").to_a
551-
end
543+
posts = Post.all.merge!(:includes => [ :author, :comments ], :limit => 2, :where => [ "posts.body = ?", 'hello' ], :order => "posts.id").to_a
552544
assert_equal 2, posts.size
553545
assert_equal [4,5], posts.collect { |p| p.id }
554546
end
@@ -940,13 +932,7 @@ def test_preconfigured_includes_with_has_many_and_habtm
940932
end
941933

942934
def test_count_with_include
943-
if current_adapter?(:SybaseAdapter)
944-
assert_equal 3, authors(:david).posts_with_comments.where("len(comments.body) > 15").references(:comments).count
945-
elsif current_adapter?(:OpenBaseAdapter)
946-
assert_equal 3, authors(:david).posts_with_comments.where("length(FETCHBLOB(comments.body)) > 15").references(:comments).count
947-
else
948-
assert_equal 3, authors(:david).posts_with_comments.where("length(comments.body) > 15").references(:comments).count
949-
end
935+
assert_equal 3, authors(:david).posts_with_comments.where("length(comments.body) > 15").references(:comments).count
950936
end
951937

952938
def test_load_with_sti_sharing_association

activerecord/test/cases/base_test.rb

+12-25
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,11 @@ def test_table_exists
160160
end
161161

162162
def test_preserving_date_objects
163-
if current_adapter?(:SybaseAdapter)
164-
# Sybase ctlib does not (yet?) support the date type; use datetime instead.
165-
assert_kind_of(
166-
Time, Topic.find(1).last_read,
167-
"The last_read attribute should be of the Time class"
168-
)
169-
else
170-
# Oracle enhanced adapter allows to define Date attributes in model class (see topic.rb)
171-
assert_kind_of(
172-
Date, Topic.find(1).last_read,
173-
"The last_read attribute should be of the Date class"
174-
)
175-
end
163+
# Oracle enhanced adapter allows to define Date attributes in model class (see topic.rb)
164+
assert_kind_of(
165+
Date, Topic.find(1).last_read,
166+
"The last_read attribute should be of the Date class"
167+
)
176168
end
177169

178170
def test_previously_changed
@@ -480,8 +472,8 @@ def test_default_values
480472
end
481473
end
482474

483-
# Oracle, and Sybase do not have a TIME datatype.
484-
unless current_adapter?(:OracleAdapter, :SybaseAdapter)
475+
# Oracle does not have a TIME datatype.
476+
unless current_adapter?(:OracleAdapter)
485477
def test_utc_as_time_zone
486478
with_timezone_config default: :utc do
487479
attributes = { "bonus_time" => "5:42:00AM" }
@@ -515,12 +507,7 @@ def test_default_values_on_empty_strings
515507
topic = Topic.find(topic.id)
516508
assert_nil topic.last_read
517509

518-
# Sybase adapter does not allow nulls in boolean columns
519-
if current_adapter?(:SybaseAdapter)
520-
assert topic.approved == false
521-
else
522-
assert_nil topic.approved
523-
end
510+
assert_nil topic.approved
524511
end
525512

526513
def test_equality
@@ -685,8 +672,8 @@ def test_group_weirds_by_from
685672
end
686673

687674
def test_attributes_on_dummy_time
688-
# Oracle, and Sybase do not have a TIME datatype.
689-
return true if current_adapter?(:OracleAdapter, :SybaseAdapter)
675+
# Oracle does not have a TIME datatype.
676+
return true if current_adapter?(:OracleAdapter)
690677

691678
with_timezone_config default: :local do
692679
attributes = {
@@ -699,8 +686,8 @@ def test_attributes_on_dummy_time
699686
end
700687

701688
def test_attributes_on_dummy_time_with_invalid_time
702-
# Oracle, and Sybase do not have a TIME datatype.
703-
return true if current_adapter?(:OracleAdapter, :SybaseAdapter)
689+
# Oracle does not have a TIME datatype.
690+
return true if current_adapter?(:OracleAdapter)
704691

705692
attributes = {
706693
"bonus_time" => "not a time"

activerecord/test/cases/binary_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
require "cases/helper"
33

44
# Without using prepared statements, it makes no sense to test
5-
# BLOB data with DB2 or Firebird, because the length of a statement
5+
# BLOB data with DB2, because the length of a statement
66
# is limited to 32KB.
7-
unless current_adapter?(:SybaseAdapter, :DB2Adapter, :FirebirdAdapter)
7+
unless current_adapter?(:DB2Adapter)
88
require 'models/binary'
99

1010
class BinaryTest < ActiveRecord::TestCase

activerecord/test/cases/defaults_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_nil_defaults_for_not_null_columns
1818
end
1919
end
2020

21-
if current_adapter?(:PostgreSQLAdapter, :FirebirdAdapter, :OpenBaseAdapter, :OracleAdapter)
21+
if current_adapter?(:PostgreSQLAdapter, :OracleAdapter)
2222
def test_default_integers
2323
default = Default.new
2424
assert_instance_of Fixnum, default.positive_integer

activerecord/test/cases/inheritance_test.rb

-8
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,8 @@ def test_base_class_activerecord_error
9595
end
9696

9797
def test_a_bad_type_column
98-
#SQLServer need to turn Identity Insert On before manually inserting into the Identity column
99-
if current_adapter?(:SybaseAdapter)
100-
Company.connection.execute "SET IDENTITY_INSERT companies ON"
101-
end
10298
Company.connection.insert "INSERT INTO companies (id, #{QUOTED_TYPE}, name) VALUES(100, 'bad_class!', 'Not happening')"
10399

104-
#We then need to turn it back Off before continuing.
105-
if current_adapter?(:SybaseAdapter)
106-
Company.connection.execute "SET IDENTITY_INSERT companies OFF"
107-
end
108100
assert_raise(ActiveRecord::SubclassNotFound) { Company.find(100) }
109101
end
110102

activerecord/test/cases/locking_test.rb

+1-3
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,6 @@ def test_destroy_dependents
339339
def add_counter_column_to(model, col='test_count')
340340
model.connection.add_column model.table_name, col, :integer, :null => false, :default => 0
341341
model.reset_column_information
342-
# OpenBase does not set a value to existing rows when adding a not null default column
343-
model.update_all(col => 0) if current_adapter?(:OpenBaseAdapter)
344342
end
345343

346344
def remove_counter_column_from(model, col = :test_count)
@@ -367,7 +365,7 @@ def counter_test(model, expected_count)
367365
# is so cumbersome. Will deadlock Ruby threads if the underlying db.execute
368366
# blocks, so separate script called by Kernel#system is needed.
369367
# (See exec vs. async_exec in the PostgreSQL adapter.)
370-
unless current_adapter?(:SybaseAdapter, :OpenBaseAdapter) || in_memory_db?
368+
unless in_memory_db?
371369
class PessimisticLockingTest < ActiveRecord::TestCase
372370
self.use_transactional_fixtures = false
373371
fixtures :people, :readers

activerecord/test/cases/migration/change_schema_test.rb

+3-10
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ def test_create_table_without_a_block
204204
connection.create_table table_name
205205
end
206206

207-
# Sybase, and SQLite3 will not allow you to add a NOT NULL
207+
# SQLite3 will not allow you to add a NOT NULL
208208
# column to a table without a default value.
209-
unless current_adapter?(:SybaseAdapter, :SQLite3Adapter)
209+
unless current_adapter?(:SQLite3Adapter)
210210
def test_add_column_not_null_without_default
211211
connection.create_table :testings do |t|
212212
t.column :foo, :string
@@ -225,18 +225,11 @@ def test_add_column_not_null_with_default
225225
end
226226

227227
con = connection
228-
connection.enable_identity_insert("testings", true) if current_adapter?(:SybaseAdapter)
229228
connection.execute "insert into testings (#{con.quote_column_name('id')}, #{con.quote_column_name('foo')}) values (1, 'hello')"
230-
connection.enable_identity_insert("testings", false) if current_adapter?(:SybaseAdapter)
231229
assert_nothing_raised {connection.add_column :testings, :bar, :string, :null => false, :default => "default" }
232230

233231
assert_raises(ActiveRecord::StatementInvalid) do
234-
unless current_adapter?(:OpenBaseAdapter)
235-
connection.execute "insert into testings (#{con.quote_column_name('id')}, #{con.quote_column_name('foo')}, #{con.quote_column_name('bar')}) values (2, 'hello', NULL)"
236-
else
237-
connection.insert("INSERT INTO testings (#{con.quote_column_name('id')}, #{con.quote_column_name('foo')}, #{con.quote_column_name('bar')}) VALUES (2, 'hello', NULL)",
238-
"Testing Insert","id",2)
239-
end
232+
connection.execute "insert into testings (#{con.quote_column_name('id')}, #{con.quote_column_name('foo')}, #{con.quote_column_name('bar')}) values (2, 'hello', NULL)"
240233
end
241234
end
242235

activerecord/test/cases/migration/column_attributes_test.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_native_decimal_insert_manual_vs_automatic
6262
# Do a manual insertion
6363
if current_adapter?(:OracleAdapter)
6464
connection.execute "insert into test_models (id, wealth) values (people_seq.nextval, 12345678901234567890.0123456789)"
65-
elsif current_adapter?(:OpenBaseAdapter) || (current_adapter?(:MysqlAdapter) && Mysql.client_version < 50003) #before mysql 5.0.3 decimals stored as strings
65+
elsif current_adapter?(:MysqlAdapter) && Mysql.client_version < 50003 #before mysql 5.0.3 decimals stored as strings
6666
connection.execute "insert into test_models (wealth) values ('12345678901234567890.0123456789')"
6767
elsif current_adapter?(:PostgreSQLAdapter)
6868
connection.execute "insert into test_models (wealth) values (12345678901234567890.0123456789)"
@@ -160,8 +160,8 @@ def test_native_types
160160
assert_equal Fixnum, bob.age.class
161161
assert_equal Time, bob.birthday.class
162162

163-
if current_adapter?(:OracleAdapter, :SybaseAdapter)
164-
# Sybase, and Oracle don't differentiate between date/time
163+
if current_adapter?(:OracleAdapter)
164+
# Oracle doesn't differentiate between date/time
165165
assert_equal Time, bob.favorite_day.class
166166
else
167167
assert_equal Date, bob.favorite_day.class

0 commit comments

Comments
 (0)