mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove SQL Server cases from tests for latest adapter work to pass rails expected behavior.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
This commit is contained in:
parent
aeae79dc45
commit
8e4624be9e
11 changed files with 17 additions and 153 deletions
|
@ -3,11 +3,9 @@ require "active_support/test_case"
|
|||
module ActiveRecord
|
||||
class TestCase < ActiveSupport::TestCase #:nodoc:
|
||||
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
|
||||
if current_adapter?(:SQLServerAdapter)
|
||||
assert_equal expected.strftime("%Y/%m/%d 00:00:00"), actual.strftime("%Y/%m/%d 00:00:00")
|
||||
elsif current_adapter?(:SybaseAdapter)
|
||||
if current_adapter?(:SybaseAdapter)
|
||||
assert_equal expected.to_s, actual.to_date.to_s, message
|
||||
else
|
||||
assert_equal expected.to_s, actual.to_s, message
|
||||
|
|
|
@ -1,95 +0,0 @@
|
|||
require "cases/helper"
|
||||
require 'models/default'
|
||||
require 'models/post'
|
||||
require 'models/task'
|
||||
|
||||
class SqlServerAdapterTest < ActiveRecord::TestCase
|
||||
class TableWithRealColumn < ActiveRecord::Base; end
|
||||
|
||||
fixtures :posts, :tasks
|
||||
|
||||
def setup
|
||||
@connection = ActiveRecord::Base.connection
|
||||
end
|
||||
|
||||
def teardown
|
||||
@connection.execute("SET LANGUAGE us_english") rescue nil
|
||||
end
|
||||
|
||||
def test_real_column_has_float_type
|
||||
assert_equal :float, TableWithRealColumn.columns_hash["real_number"].type
|
||||
end
|
||||
|
||||
# SQL Server 2000 has a bug where some unambiguous date formats are not
|
||||
# correctly identified if the session language is set to german
|
||||
def test_date_insertion_when_language_is_german
|
||||
@connection.execute("SET LANGUAGE deutsch")
|
||||
|
||||
assert_nothing_raised do
|
||||
Task.create(:starting => Time.utc(2000, 1, 31, 5, 42, 0), :ending => Date.new(2006, 12, 31))
|
||||
end
|
||||
end
|
||||
|
||||
def test_indexes_with_descending_order
|
||||
# Make sure we have an index with descending order
|
||||
@connection.execute "CREATE INDEX idx_credit_limit ON accounts (credit_limit DESC)" rescue nil
|
||||
assert_equal ["credit_limit"], @connection.indexes('accounts').first.columns
|
||||
ensure
|
||||
@connection.execute "DROP INDEX accounts.idx_credit_limit"
|
||||
end
|
||||
|
||||
def test_execute_without_block_closes_statement
|
||||
assert_all_statements_used_are_closed do
|
||||
@connection.execute("SELECT 1")
|
||||
end
|
||||
end
|
||||
|
||||
def test_execute_with_block_closes_statement
|
||||
assert_all_statements_used_are_closed do
|
||||
@connection.execute("SELECT 1") do |sth|
|
||||
assert !sth.finished?, "Statement should still be alive within block"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_insert_with_identity_closes_statement
|
||||
assert_all_statements_used_are_closed do
|
||||
@connection.insert("INSERT INTO accounts ([id], [firm_id],[credit_limit]) values (999, 1, 50)")
|
||||
end
|
||||
end
|
||||
|
||||
def test_insert_without_identity_closes_statement
|
||||
assert_all_statements_used_are_closed do
|
||||
@connection.insert("INSERT INTO accounts ([firm_id],[credit_limit]) values (1, 50)")
|
||||
end
|
||||
end
|
||||
|
||||
def test_active_closes_statement
|
||||
assert_all_statements_used_are_closed do
|
||||
@connection.active?
|
||||
end
|
||||
end
|
||||
|
||||
def assert_all_statements_used_are_closed(&block)
|
||||
existing_handles = []
|
||||
ObjectSpace.each_object(DBI::StatementHandle) {|handle| existing_handles << handle}
|
||||
GC.disable
|
||||
|
||||
yield
|
||||
|
||||
used_handles = []
|
||||
ObjectSpace.each_object(DBI::StatementHandle) {|handle| used_handles << handle unless existing_handles.include? handle}
|
||||
|
||||
assert_block "No statements were used within given block" do
|
||||
used_handles.size > 0
|
||||
end
|
||||
|
||||
ObjectSpace.each_object(DBI::StatementHandle) do |handle|
|
||||
assert_block "Statement should have been closed within given block" do
|
||||
handle.finished?
|
||||
end
|
||||
end
|
||||
ensure
|
||||
GC.enable
|
||||
end
|
||||
end
|
|
@ -667,7 +667,7 @@ class EagerAssociationTest < ActiveRecord::TestCase
|
|||
end
|
||||
|
||||
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")
|
||||
elsif current_adapter?(:OpenBaseAdapter)
|
||||
assert_equal 3, authors(:david).posts_with_comments.count(:conditions => "length(FETCHBLOB(comments.body)) > 15")
|
||||
|
|
|
@ -428,9 +428,6 @@ class BasicsTest < ActiveRecord::TestCase
|
|||
end
|
||||
|
||||
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)
|
||||
# Sybase ctlib does not (yet?) support the date type; use datetime instead.
|
||||
# Oracle treats all dates/times as Time.
|
||||
|
@ -777,8 +774,8 @@ class BasicsTest < ActiveRecord::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
# Oracle, SQLServer, and Sybase do not have a TIME datatype.
|
||||
unless current_adapter?(:SQLServerAdapter, :OracleAdapter, :SybaseAdapter)
|
||||
# Oracle, and Sybase do not have a TIME datatype.
|
||||
unless current_adapter?(:OracleAdapter, :SybaseAdapter)
|
||||
def test_utc_as_time_zone
|
||||
Topic.default_timezone = :utc
|
||||
attributes = { "bonus_time" => "5:42:00AM" }
|
||||
|
@ -1157,8 +1154,8 @@ class BasicsTest < ActiveRecord::TestCase
|
|||
end
|
||||
|
||||
def test_attributes_on_dummy_time
|
||||
# Oracle, SQL Server, and Sybase do not have a TIME datatype.
|
||||
return true if current_adapter?(:SQLServerAdapter, :OracleAdapter, :SybaseAdapter)
|
||||
# Oracle, and Sybase do not have a TIME datatype.
|
||||
return true if current_adapter?(:OracleAdapter, :SybaseAdapter)
|
||||
|
||||
attributes = {
|
||||
"bonus_time" => "5:42:00AM"
|
||||
|
@ -1874,7 +1871,7 @@ class BasicsTest < ActiveRecord::TestCase
|
|||
assert_equal "integer", xml.elements["//parent-id"].attributes['type']
|
||||
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 "datetime" , xml.elements["//last-read"].attributes['type']
|
||||
else
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
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
|
||||
# BLOB data with DB2 or Firebird, because the length of a statement
|
||||
# is limited to 32KB.
|
||||
unless current_adapter?(:SQLServerAdapter, :SybaseAdapter, :DB2Adapter, :FirebirdAdapter)
|
||||
unless current_adapter?(:SybaseAdapter, :DB2Adapter, :FirebirdAdapter)
|
||||
require 'models/binary'
|
||||
|
||||
class BinaryTest < ActiveRecord::TestCase
|
||||
|
|
|
@ -78,7 +78,7 @@ class DefaultTest < ActiveRecord::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
if current_adapter?(:PostgreSQLAdapter, :SQLServerAdapter, :FirebirdAdapter, :OpenBaseAdapter, :OracleAdapter)
|
||||
if current_adapter?(:PostgreSQLAdapter, :FirebirdAdapter, :OpenBaseAdapter, :OracleAdapter)
|
||||
def test_default_integers
|
||||
default = Default.new
|
||||
assert_instance_of Fixnum, default.positive_integer
|
||||
|
|
|
@ -59,13 +59,13 @@ class InheritanceTest < ActiveRecord::TestCase
|
|||
|
||||
def test_a_bad_type_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"
|
||||
end
|
||||
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.
|
||||
if current_adapter?(:SQLServerAdapter, :SybaseAdapter)
|
||||
if current_adapter?(:SybaseAdapter)
|
||||
Company.connection.execute "SET IDENTITY_INSERT companies OFF"
|
||||
end
|
||||
assert_raises(ActiveRecord::SubclassNotFound) { Company.find(100) }
|
||||
|
|
|
@ -200,9 +200,9 @@ end
|
|||
# blocks, so separate script called by Kernel#system is needed.
|
||||
# (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
|
||||
self.use_transactional_fixtures = false
|
||||
fixtures :people, :readers
|
||||
|
|
|
@ -271,9 +271,9 @@ if ActiveRecord::Base.connection.supports_migrations?
|
|||
Person.connection.drop_table table_name rescue nil
|
||||
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.
|
||||
unless current_adapter?(:SQLServerAdapter, :SybaseAdapter, :SQLiteAdapter)
|
||||
unless current_adapter?(:SybaseAdapter, :SQLiteAdapter)
|
||||
def test_add_column_not_null_without_default
|
||||
Person.connection.create_table :testings do |t|
|
||||
t.column :foo, :string
|
||||
|
@ -410,7 +410,7 @@ if ActiveRecord::Base.connection.supports_migrations?
|
|||
assert_equal Fixnum, bob.age.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
|
||||
assert_equal Time, bob.favorite_day.class
|
||||
else
|
||||
|
@ -851,10 +851,6 @@ if ActiveRecord::Base.connection.supports_migrations?
|
|||
# - SQLite3 stores a float, in violation of SQL
|
||||
assert_kind_of BigDecimal, 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
|
||||
# - SQL standard is an integer
|
||||
assert_kind_of Fixnum, b.value_of_e
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
require "cases/helper"
|
||||
require 'active_record/schema'
|
||||
|
||||
if ActiveRecord::Base.connection.supports_migrations?
|
||||
class Order < ActiveRecord::Base
|
||||
self.table_name = '[order]'
|
||||
end
|
||||
|
||||
class TableNameTest < ActiveRecord::TestCase
|
||||
self.use_transactional_fixtures = false
|
||||
|
||||
# Ensures Model.columns works when using SQLServer escape characters.
|
||||
# Enables legacy schemas using SQL reserved words as table names.
|
||||
# Should work with table names with spaces as well ('table name').
|
||||
def test_escaped_table_name
|
||||
assert_nothing_raised do
|
||||
ActiveRecord::Base.connection.select_all 'SELECT * FROM [order]'
|
||||
end
|
||||
assert_equal '[order]', Order.table_name
|
||||
assert_equal 5, Order.columns.length
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,5 +0,0 @@
|
|||
ActiveRecord::Schema.define do
|
||||
create_table :table_with_real_columns, :force => true do |t|
|
||||
t.column :real_number, :real
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue