Skip to content

Commit

Permalink
Remove SQL Server cases from tests for latest adapter work to pass ra…
Browse files Browse the repository at this point in the history
…ils expected behavior.

Signed-off-by: Michael Koziarski <michael@koziarski.com>
  • Loading branch information
metaskills authored and NZKoz committed Nov 19, 2008
1 parent 4f20a15 commit 7a9c48c
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 153 deletions.
6 changes: 2 additions & 4 deletions activerecord/lib/active_record/test_case.rb
Expand Up @@ -11,11 +11,9 @@ def create_fixtures(*table_names, &block)
end end


def assert_date_from_db(expected, actual, message = nil) def assert_date_from_db(expected, actual, message = nil)
# SQL Server doesn't have a separate column type just for dates, # SybaseAdapter doesn't have a separate column type just for dates,
# so the time is in the string and incorrectly formatted # so the time is in the string and incorrectly formatted
if current_adapter?(:SQLServerAdapter) if current_adapter?(:SybaseAdapter)
assert_equal expected.strftime("%Y/%m/%d 00:00:00"), actual.strftime("%Y/%m/%d 00:00:00")
elsif current_adapter?(:SybaseAdapter)
assert_equal expected.to_s, actual.to_date.to_s, message assert_equal expected.to_s, actual.to_date.to_s, message
else else
assert_equal expected.to_s, actual.to_s, message assert_equal expected.to_s, actual.to_s, message
Expand Down
95 changes: 0 additions & 95 deletions activerecord/test/cases/adapter_test_sqlserver.rb

This file was deleted.

2 changes: 1 addition & 1 deletion activerecord/test/cases/associations/eager_test.rb
Expand Up @@ -667,7 +667,7 @@ def test_preconfigured_includes_with_has_many_and_habtm
end end


def test_count_with_include def test_count_with_include
if current_adapter?(:SQLServerAdapter, :SybaseAdapter) if current_adapter?(:SybaseAdapter)
assert_equal 3, authors(:david).posts_with_comments.count(:conditions => "len(comments.body) > 15") assert_equal 3, authors(:david).posts_with_comments.count(:conditions => "len(comments.body) > 15")
elsif current_adapter?(:OpenBaseAdapter) elsif current_adapter?(:OpenBaseAdapter)
assert_equal 3, authors(:david).posts_with_comments.count(:conditions => "length(FETCHBLOB(comments.body)) > 15") assert_equal 3, authors(:david).posts_with_comments.count(:conditions => "length(FETCHBLOB(comments.body)) > 15")
Expand Down
13 changes: 5 additions & 8 deletions activerecord/test/cases/base_test.rb
Expand Up @@ -428,9 +428,6 @@ def test_non_attribute_access_and_assignment
end end


def test_preserving_date_objects def test_preserving_date_objects
# SQL Server doesn't have a separate column type just for dates, so all are returned as time
return true if current_adapter?(:SQLServerAdapter)

if current_adapter?(:SybaseAdapter, :OracleAdapter) if current_adapter?(:SybaseAdapter, :OracleAdapter)
# Sybase ctlib does not (yet?) support the date type; use datetime instead. # Sybase ctlib does not (yet?) support the date type; use datetime instead.
# Oracle treats all dates/times as Time. # Oracle treats all dates/times as Time.
Expand Down Expand Up @@ -777,8 +774,8 @@ def test_default_values
end end
end end


# Oracle, SQLServer, and Sybase do not have a TIME datatype. # Oracle, and Sybase do not have a TIME datatype.
unless current_adapter?(:SQLServerAdapter, :OracleAdapter, :SybaseAdapter) unless current_adapter?(:OracleAdapter, :SybaseAdapter)
def test_utc_as_time_zone def test_utc_as_time_zone
Topic.default_timezone = :utc Topic.default_timezone = :utc
attributes = { "bonus_time" => "5:42:00AM" } attributes = { "bonus_time" => "5:42:00AM" }
Expand Down Expand Up @@ -1157,8 +1154,8 @@ def test_multiparameter_assignment_of_aggregation
end end


def test_attributes_on_dummy_time def test_attributes_on_dummy_time
# Oracle, SQL Server, and Sybase do not have a TIME datatype. # Oracle, and Sybase do not have a TIME datatype.
return true if current_adapter?(:SQLServerAdapter, :OracleAdapter, :SybaseAdapter) return true if current_adapter?(:OracleAdapter, :SybaseAdapter)


attributes = { attributes = {
"bonus_time" => "5:42:00AM" "bonus_time" => "5:42:00AM"
Expand Down Expand Up @@ -1874,7 +1871,7 @@ def test_to_xml
assert_equal "integer", xml.elements["//parent-id"].attributes['type'] assert_equal "integer", xml.elements["//parent-id"].attributes['type']
assert_equal "true", xml.elements["//parent-id"].attributes['nil'] assert_equal "true", xml.elements["//parent-id"].attributes['nil']


if current_adapter?(:SybaseAdapter, :SQLServerAdapter, :OracleAdapter) if current_adapter?(:SybaseAdapter, :OracleAdapter)
assert_equal last_read_in_current_timezone, xml.elements["//last-read"].text assert_equal last_read_in_current_timezone, xml.elements["//last-read"].text
assert_equal "datetime" , xml.elements["//last-read"].attributes['type'] assert_equal "datetime" , xml.elements["//last-read"].attributes['type']
else else
Expand Down
6 changes: 1 addition & 5 deletions activerecord/test/cases/binary_test.rb
@@ -1,13 +1,9 @@
require "cases/helper" require "cases/helper"


# Without using prepared statements, it makes no sense to test
# BLOB data with SQL Server, because the length of a statement is
# limited to 8KB.
#
# Without using prepared statements, it makes no sense to test # Without using prepared statements, it makes no sense to test
# BLOB data with DB2 or Firebird, because the length of a statement # BLOB data with DB2 or Firebird, because the length of a statement
# is limited to 32KB. # is limited to 32KB.
unless current_adapter?(:SQLServerAdapter, :SybaseAdapter, :DB2Adapter, :FirebirdAdapter) unless current_adapter?(:SybaseAdapter, :DB2Adapter, :FirebirdAdapter)
require 'models/binary' require 'models/binary'


class BinaryTest < ActiveRecord::TestCase class BinaryTest < ActiveRecord::TestCase
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/cases/defaults_test.rb
Expand Up @@ -78,7 +78,7 @@ def test_mysql_integer_not_null_defaults
end end
end end


if current_adapter?(:PostgreSQLAdapter, :SQLServerAdapter, :FirebirdAdapter, :OpenBaseAdapter, :OracleAdapter) if current_adapter?(:PostgreSQLAdapter, :FirebirdAdapter, :OpenBaseAdapter, :OracleAdapter)
def test_default_integers def test_default_integers
default = Default.new default = Default.new
assert_instance_of Fixnum, default.positive_integer assert_instance_of Fixnum, default.positive_integer
Expand Down
4 changes: 2 additions & 2 deletions activerecord/test/cases/inheritance_test.rb
Expand Up @@ -59,13 +59,13 @@ def test_company_descends_from_active_record


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


#We then need to turn it back Off before continuing. #We then need to turn it back Off before continuing.
if current_adapter?(:SQLServerAdapter, :SybaseAdapter) if current_adapter?(:SybaseAdapter)
Company.connection.execute "SET IDENTITY_INSERT companies OFF" Company.connection.execute "SET IDENTITY_INSERT companies OFF"
end end
assert_raises(ActiveRecord::SubclassNotFound) { Company.find(100) } assert_raises(ActiveRecord::SubclassNotFound) { Company.find(100) }
Expand Down
4 changes: 2 additions & 2 deletions activerecord/test/cases/locking_test.rb
Expand Up @@ -200,9 +200,9 @@ def counter_test(model, expected_count)
# blocks, so separate script called by Kernel#system is needed. # blocks, so separate script called by Kernel#system is needed.
# (See exec vs. async_exec in the PostgreSQL adapter.) # (See exec vs. async_exec in the PostgreSQL adapter.)


# TODO: The SQL Server, Sybase, and OpenBase adapters currently have no support for pessimistic locking # TODO: The Sybase, and OpenBase adapters currently have no support for pessimistic locking


unless current_adapter?(:SQLServerAdapter, :SybaseAdapter, :OpenBaseAdapter) unless current_adapter?(:SybaseAdapter, :OpenBaseAdapter)
class PessimisticLockingTest < ActiveRecord::TestCase class PessimisticLockingTest < ActiveRecord::TestCase
self.use_transactional_fixtures = false self.use_transactional_fixtures = false
fixtures :people, :readers fixtures :people, :readers
Expand Down
10 changes: 3 additions & 7 deletions activerecord/test/cases/migration_test.rb
Expand Up @@ -271,9 +271,9 @@ def test_create_table_with_timestamps_should_create_datetime_columns_with_option
Person.connection.drop_table table_name rescue nil Person.connection.drop_table table_name rescue nil
end end


# SQL Server, Sybase, and SQLite3 will not allow you to add a NOT NULL # Sybase, and SQLite3 will not allow you to add a NOT NULL
# column to a table without a default value. # column to a table without a default value.
unless current_adapter?(:SQLServerAdapter, :SybaseAdapter, :SQLiteAdapter) unless current_adapter?(:SybaseAdapter, :SQLiteAdapter)
def test_add_column_not_null_without_default def test_add_column_not_null_without_default
Person.connection.create_table :testings do |t| Person.connection.create_table :testings do |t|
t.column :foo, :string t.column :foo, :string
Expand Down Expand Up @@ -410,7 +410,7 @@ def test_native_types
assert_equal Fixnum, bob.age.class assert_equal Fixnum, bob.age.class
assert_equal Time, bob.birthday.class assert_equal Time, bob.birthday.class


if current_adapter?(:SQLServerAdapter, :OracleAdapter, :SybaseAdapter) if current_adapter?(:OracleAdapter, :SybaseAdapter)
# Sybase, and Oracle don't differentiate between date/time # Sybase, and Oracle don't differentiate between date/time
assert_equal Time, bob.favorite_day.class assert_equal Time, bob.favorite_day.class
else else
Expand Down Expand Up @@ -851,10 +851,6 @@ def test_add_table_with_decimals
# - SQLite3 stores a float, in violation of SQL # - SQLite3 stores a float, in violation of SQL
assert_kind_of BigDecimal, b.value_of_e assert_kind_of BigDecimal, b.value_of_e
assert_equal BigDecimal("2.71828182845905"), b.value_of_e assert_equal BigDecimal("2.71828182845905"), b.value_of_e
elsif current_adapter?(:SQLServer)
# - SQL Server rounds instead of truncating
assert_kind_of Fixnum, b.value_of_e
assert_equal 3, b.value_of_e
else else
# - SQL standard is an integer # - SQL standard is an integer
assert_kind_of Fixnum, b.value_of_e assert_kind_of Fixnum, b.value_of_e
Expand Down
23 changes: 0 additions & 23 deletions activerecord/test/cases/table_name_test_sqlserver.rb

This file was deleted.

5 changes: 0 additions & 5 deletions activerecord/test/schema/sqlserver_specific_schema.rb

This file was deleted.

0 comments on commit 7a9c48c

Please sign in to comment.