Skip to content
This repository
Browse code

Remove SQL Server cases from tests for latest adapter work to pass ra…

…ils expected behavior.

Signed-off-by: Michael Koziarski <michael@koziarski.com>
  • Loading branch information...
commit 8e4624be9e55cd0865b307be70a1e6287ec033ca 1 parent aeae79d
Ken Collins authored November 19, 2008 NZKoz committed November 19, 2008
6  activerecord/lib/active_record/test_case.rb
@@ -3,11 +3,9 @@
3 3
 module ActiveRecord
4 4
   class TestCase < ActiveSupport::TestCase #:nodoc:
5 5
     def assert_date_from_db(expected, actual, message = nil)
6  
-      # SQL Server doesn't have a separate column type just for dates,
  6
+      # SybaseAdapter doesn't have a separate column type just for dates,
7 7
       # so the time is in the string and incorrectly formatted
8  
-      if current_adapter?(:SQLServerAdapter)
9  
-        assert_equal expected.strftime("%Y/%m/%d 00:00:00"), actual.strftime("%Y/%m/%d 00:00:00")
10  
-      elsif current_adapter?(:SybaseAdapter)
  8
+      if current_adapter?(:SybaseAdapter)
11 9
         assert_equal expected.to_s, actual.to_date.to_s, message
12 10
       else
13 11
         assert_equal expected.to_s, actual.to_s, message
95  activerecord/test/cases/adapter_test_sqlserver.rb
... ...
@@ -1,95 +0,0 @@
1  
-require "cases/helper"
2  
-require 'models/default'
3  
-require 'models/post'
4  
-require 'models/task'
5  
-
6  
-class SqlServerAdapterTest < ActiveRecord::TestCase
7  
-  class TableWithRealColumn < ActiveRecord::Base; end
8  
-
9  
-  fixtures :posts, :tasks
10  
-
11  
-  def setup
12  
-    @connection = ActiveRecord::Base.connection
13  
-  end
14  
-
15  
-  def teardown
16  
-    @connection.execute("SET LANGUAGE us_english") rescue nil
17  
-  end
18  
-
19  
-  def test_real_column_has_float_type
20  
-    assert_equal :float, TableWithRealColumn.columns_hash["real_number"].type
21  
-  end
22  
-
23  
-  # SQL Server 2000 has a bug where some unambiguous date formats are not
24  
-  # correctly identified if the session language is set to german
25  
-  def test_date_insertion_when_language_is_german
26  
-    @connection.execute("SET LANGUAGE deutsch")
27  
-
28  
-    assert_nothing_raised do
29  
-      Task.create(:starting => Time.utc(2000, 1, 31, 5, 42, 0), :ending => Date.new(2006, 12, 31))
30  
-    end
31  
-  end
32  
-
33  
-  def test_indexes_with_descending_order
34  
-    # Make sure we have an index with descending order
35  
-    @connection.execute "CREATE INDEX idx_credit_limit ON accounts (credit_limit DESC)" rescue nil
36  
-    assert_equal ["credit_limit"], @connection.indexes('accounts').first.columns
37  
-  ensure
38  
-    @connection.execute "DROP INDEX accounts.idx_credit_limit"
39  
-  end
40  
-
41  
-  def test_execute_without_block_closes_statement
42  
-    assert_all_statements_used_are_closed do
43  
-      @connection.execute("SELECT 1")
44  
-    end
45  
-  end
46  
-
47  
-  def test_execute_with_block_closes_statement
48  
-    assert_all_statements_used_are_closed do
49  
-      @connection.execute("SELECT 1") do |sth|
50  
-        assert !sth.finished?, "Statement should still be alive within block"
51  
-      end
52  
-    end
53  
-  end
54  
-
55  
-  def test_insert_with_identity_closes_statement
56  
-    assert_all_statements_used_are_closed do
57  
-      @connection.insert("INSERT INTO accounts ([id], [firm_id],[credit_limit]) values (999, 1, 50)")
58  
-    end
59  
-  end
60  
-
61  
-  def test_insert_without_identity_closes_statement
62  
-    assert_all_statements_used_are_closed do
63  
-      @connection.insert("INSERT INTO accounts ([firm_id],[credit_limit]) values (1, 50)")
64  
-    end
65  
-  end
66  
-
67  
-  def test_active_closes_statement
68  
-    assert_all_statements_used_are_closed do
69  
-      @connection.active?
70  
-    end
71  
-  end
72  
-
73  
-  def assert_all_statements_used_are_closed(&block)
74  
-    existing_handles = []
75  
-    ObjectSpace.each_object(DBI::StatementHandle) {|handle| existing_handles << handle}
76  
-    GC.disable
77  
-
78  
-    yield
79  
-
80  
-    used_handles = []
81  
-    ObjectSpace.each_object(DBI::StatementHandle) {|handle| used_handles << handle unless existing_handles.include? handle}
82  
-
83  
-    assert_block "No statements were used within given block" do
84  
-      used_handles.size > 0
85  
-    end
86  
-
87  
-    ObjectSpace.each_object(DBI::StatementHandle) do |handle|
88  
-      assert_block "Statement should have been closed within given block" do
89  
-        handle.finished?
90  
-      end
91  
-    end
92  
-  ensure
93  
-    GC.enable
94  
-  end
95  
-end
2  activerecord/test/cases/associations/eager_test.rb
@@ -667,7 +667,7 @@ def test_preconfigured_includes_with_has_many_and_habtm
667 667
   end
668 668
 
669 669
   def test_count_with_include
670  
-    if current_adapter?(:SQLServerAdapter, :SybaseAdapter)
  670
+    if current_adapter?(:SybaseAdapter)
671 671
       assert_equal 3, authors(:david).posts_with_comments.count(:conditions => "len(comments.body) > 15")
672 672
     elsif current_adapter?(:OpenBaseAdapter)
673 673
       assert_equal 3, authors(:david).posts_with_comments.count(:conditions => "length(FETCHBLOB(comments.body)) > 15")
13  activerecord/test/cases/base_test.rb
@@ -428,9 +428,6 @@ def test_non_attribute_access_and_assignment
428 428
   end
429 429
 
430 430
   def test_preserving_date_objects
431  
-    # SQL Server doesn't have a separate column type just for dates, so all are returned as time
432  
-    return true if current_adapter?(:SQLServerAdapter)
433  
-
434 431
     if current_adapter?(:SybaseAdapter, :OracleAdapter)
435 432
       # Sybase ctlib does not (yet?) support the date type; use datetime instead.
436 433
       # Oracle treats all dates/times as Time.
@@ -777,8 +774,8 @@ def test_default_values
777 774
     end
778 775
   end
779 776
 
780  
-  # Oracle, SQLServer, and Sybase do not have a TIME datatype.
781  
-  unless current_adapter?(:SQLServerAdapter, :OracleAdapter, :SybaseAdapter)
  777
+  # Oracle, and Sybase do not have a TIME datatype.
  778
+  unless current_adapter?(:OracleAdapter, :SybaseAdapter)
782 779
     def test_utc_as_time_zone
783 780
       Topic.default_timezone = :utc
784 781
       attributes = { "bonus_time" => "5:42:00AM" }
@@ -1157,8 +1154,8 @@ def test_multiparameter_assignment_of_aggregation
1157 1154
   end
1158 1155
 
1159 1156
   def test_attributes_on_dummy_time
1160  
-    # Oracle, SQL Server, and Sybase do not have a TIME datatype.
1161  
-    return true if current_adapter?(:SQLServerAdapter, :OracleAdapter, :SybaseAdapter)
  1157
+    # Oracle, and Sybase do not have a TIME datatype.
  1158
+    return true if current_adapter?(:OracleAdapter, :SybaseAdapter)
1162 1159
 
1163 1160
     attributes = {
1164 1161
       "bonus_time" => "5:42:00AM"
@@ -1874,7 +1871,7 @@ def test_to_xml
1874 1871
     assert_equal "integer", xml.elements["//parent-id"].attributes['type']
1875 1872
     assert_equal "true", xml.elements["//parent-id"].attributes['nil']
1876 1873
 
1877  
-    if current_adapter?(:SybaseAdapter, :SQLServerAdapter, :OracleAdapter)
  1874
+    if current_adapter?(:SybaseAdapter, :OracleAdapter)
1878 1875
       assert_equal last_read_in_current_timezone, xml.elements["//last-read"].text
1879 1876
       assert_equal "datetime" , xml.elements["//last-read"].attributes['type']
1880 1877
     else
6  activerecord/test/cases/binary_test.rb
... ...
@@ -1,13 +1,9 @@
1 1
 require "cases/helper"
2 2
 
3 3
 # Without using prepared statements, it makes no sense to test
4  
-# BLOB data with SQL Server, because the length of a statement is
5  
-# limited to 8KB.
6  
-#
7  
-# Without using prepared statements, it makes no sense to test
8 4
 # BLOB data with DB2 or Firebird, because the length of a statement
9 5
 # is limited to 32KB.
10  
-unless current_adapter?(:SQLServerAdapter, :SybaseAdapter, :DB2Adapter, :FirebirdAdapter)
  6
+unless current_adapter?(:SybaseAdapter, :DB2Adapter, :FirebirdAdapter)
11 7
   require 'models/binary'
12 8
 
13 9
   class BinaryTest < ActiveRecord::TestCase
2  activerecord/test/cases/defaults_test.rb
@@ -78,7 +78,7 @@ def test_mysql_integer_not_null_defaults
78 78
     end
79 79
   end
80 80
 
81  
-  if current_adapter?(:PostgreSQLAdapter, :SQLServerAdapter, :FirebirdAdapter, :OpenBaseAdapter, :OracleAdapter)
  81
+  if current_adapter?(:PostgreSQLAdapter, :FirebirdAdapter, :OpenBaseAdapter, :OracleAdapter)
82 82
     def test_default_integers
83 83
       default = Default.new
84 84
       assert_instance_of Fixnum, default.positive_integer
4  activerecord/test/cases/inheritance_test.rb
@@ -59,13 +59,13 @@ def test_company_descends_from_active_record
59 59
 
60 60
   def test_a_bad_type_column
61 61
     #SQLServer need to turn Identity Insert On before manually inserting into the Identity column
62  
-    if current_adapter?(:SQLServerAdapter, :SybaseAdapter)
  62
+    if current_adapter?(:SybaseAdapter)
63 63
       Company.connection.execute "SET IDENTITY_INSERT companies ON"
64 64
     end
65 65
     Company.connection.insert "INSERT INTO companies (id, #{QUOTED_TYPE}, name) VALUES(100, 'bad_class!', 'Not happening')"
66 66
 
67 67
     #We then need to turn it back Off before continuing.
68  
-    if current_adapter?(:SQLServerAdapter, :SybaseAdapter)
  68
+    if current_adapter?(:SybaseAdapter)
69 69
       Company.connection.execute "SET IDENTITY_INSERT companies OFF"
70 70
     end
71 71
     assert_raises(ActiveRecord::SubclassNotFound) { Company.find(100) }
4  activerecord/test/cases/locking_test.rb
@@ -200,9 +200,9 @@ def counter_test(model, expected_count)
200 200
 # blocks, so separate script called by Kernel#system is needed.
201 201
 # (See exec vs. async_exec in the PostgreSQL adapter.)
202 202
 
203  
-# TODO: The SQL Server, Sybase, and OpenBase adapters currently have no support for pessimistic locking
  203
+# TODO: The Sybase, and OpenBase adapters currently have no support for pessimistic locking
204 204
 
205  
-unless current_adapter?(:SQLServerAdapter, :SybaseAdapter, :OpenBaseAdapter)
  205
+unless current_adapter?(:SybaseAdapter, :OpenBaseAdapter)
206 206
   class PessimisticLockingTest < ActiveRecord::TestCase
207 207
     self.use_transactional_fixtures = false
208 208
     fixtures :people, :readers
10  activerecord/test/cases/migration_test.rb
@@ -271,9 +271,9 @@ def test_create_table_with_timestamps_should_create_datetime_columns_with_option
271 271
       Person.connection.drop_table table_name rescue nil
272 272
     end
273 273
 
274  
-    # SQL Server, Sybase, and SQLite3 will not allow you to add a NOT NULL
  274
+    # Sybase, and SQLite3 will not allow you to add a NOT NULL
275 275
     # column to a table without a default value.
276  
-    unless current_adapter?(:SQLServerAdapter, :SybaseAdapter, :SQLiteAdapter)
  276
+    unless current_adapter?(:SybaseAdapter, :SQLiteAdapter)
277 277
       def test_add_column_not_null_without_default
278 278
         Person.connection.create_table :testings do |t|
279 279
           t.column :foo, :string
@@ -410,7 +410,7 @@ def test_native_types
410 410
       assert_equal Fixnum, bob.age.class
411 411
       assert_equal Time, bob.birthday.class
412 412
 
413  
-      if current_adapter?(:SQLServerAdapter, :OracleAdapter, :SybaseAdapter)
  413
+      if current_adapter?(:OracleAdapter, :SybaseAdapter)
414 414
         # Sybase, and Oracle don't differentiate between date/time
415 415
         assert_equal Time, bob.favorite_day.class
416 416
       else
@@ -851,10 +851,6 @@ def test_add_table_with_decimals
851 851
         # - SQLite3 stores a float, in violation of SQL
852 852
         assert_kind_of BigDecimal, b.value_of_e
853 853
         assert_equal BigDecimal("2.71828182845905"), b.value_of_e
854  
-      elsif current_adapter?(:SQLServer)
855  
-        # - SQL Server rounds instead of truncating
856  
-        assert_kind_of Fixnum, b.value_of_e
857  
-        assert_equal 3, b.value_of_e
858 854
       else
859 855
         # - SQL standard is an integer
860 856
         assert_kind_of Fixnum, b.value_of_e
23  activerecord/test/cases/table_name_test_sqlserver.rb
... ...
@@ -1,23 +0,0 @@
1  
-require "cases/helper"
2  
-require 'active_record/schema'
3  
-
4  
-if ActiveRecord::Base.connection.supports_migrations?
5  
-  class Order < ActiveRecord::Base
6  
-    self.table_name = '[order]'
7  
-  end
8  
-
9  
-  class TableNameTest < ActiveRecord::TestCase
10  
-    self.use_transactional_fixtures = false
11  
-
12  
-    # Ensures Model.columns works when using SQLServer escape characters.
13  
-    # Enables legacy schemas using SQL reserved words as table names.
14  
-    # Should work with table names with spaces as well ('table name').
15  
-    def test_escaped_table_name
16  
-      assert_nothing_raised do
17  
-        ActiveRecord::Base.connection.select_all 'SELECT * FROM [order]'
18  
-      end
19  
-      assert_equal '[order]', Order.table_name
20  
-      assert_equal 5, Order.columns.length
21  
-    end
22  
-  end
23  
-end
5  activerecord/test/schema/sqlserver_specific_schema.rb
... ...
@@ -1,5 +0,0 @@
1  
-ActiveRecord::Schema.define do
2  
-  create_table :table_with_real_columns, :force => true do |t|
3  
-    t.column :real_number, :real
4  
-  end
5  
-end

2 notes on commit 8e4624b

Mike Gaffney

Was this to disable SQLServer as not working or because the SQLServer adapter got smarter?

Michael Koziarski
Owner

It was to make SQL Server run all the tests as yes, the adapter got a bunch smarter.

Please sign in to comment.
Something went wrong with that request. Please try again.