Skip to content

Commit 115c5c7

Browse files
committed
[Rails3] Updating gemspec and many test helpers that focused on 2000 being in or out of the picture.
1 parent d79c34c commit 115c5c7

12 files changed

+37
-102
lines changed

activerecord-sqlserver-adapter.gemspec

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |s|
22
s.name = "activerecord-sqlserver-adapter"
3-
s.version = "3.0.0.beta.1"
4-
s.date = "2010-07-26"
3+
s.version = "3.0.0.rc.1"
4+
s.date = "2010-08-05"
55
s.summary = "SQL Server 2005 and 2008 Adapter For Rails."
66
s.email = "ken@metaskills.net"
77
s.homepage = "http://github.com/rails-sqlserver"
@@ -16,13 +16,13 @@ Gem::Specification.new do |s|
1616
"RUNNING_UNIT_TESTS",
1717
"lib/activerecord-sqlserver-adapter.rb",
1818
"lib/active_record/connection_adapters/sqlserver_adapter.rb",
19-
"lib/active_record/connection_adapters/sqlserver_adapter/core_ext/active_record.rb",
20-
"lib/active_record/connection_adapters/sqlserver_adapter/core_ext/odbc.rb",
19+
"lib/active_record/connection_adapters/sqlserver/core_ext/active_record.rb",
20+
"lib/active_record/connection_adapters/sqlserver/core_ext/odbc.rb",
2121
"lib/active_record/connection_adapters/sqlserver/database_limits.rb",
2222
"lib/active_record/connection_adapters/sqlserver/database_statements.rb",
2323
"lib/active_record/connection_adapters/sqlserver/errors.rb",
24-
"lib/active_record/connection_adapters/sqlserver/schema_statements.rb",
2524
"lib/active_record/connection_adapters/sqlserver/quoting.rb",
25+
"lib/active_record/connection_adapters/sqlserver/schema_statements.rb",
2626
"lib/arel/engines/sql/compilers/sqlserver_compiler.rb" ]
2727
s.test_files = [
2828
"test/cases/aaaa_create_tables_test_sqlserver.rb",
@@ -37,7 +37,6 @@ Gem::Specification.new do |s|
3737
"test/cases/inheritance_test_sqlserver.rb",
3838
"test/cases/method_scoping_test_sqlserver.rb",
3939
"test/cases/migration_test_sqlserver.rb",
40-
"test/cases/named_scope_test_sqlserver.rb",
4140
"test/cases/offset_and_limit_test_sqlserver.rb",
4241
"test/cases/pessimistic_locking_test_sqlserver.rb",
4342
"test/cases/query_cache_test_sqlserver.rb",

lib/active_record/connection_adapters/sqlserver/database_limits.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def columns_per_table
2424
end
2525

2626
def indexes_per_table
27-
sqlserver_2000? ? 249 : 999
27+
999
2828
end
2929

3030
def columns_per_multicolumn_index

lib/active_record/connection_adapters/sqlserver_adapter.rb

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ def self.sqlserver_connection(config) #:nodoc:
2626
when :adonet
2727
require 'System.Data'
2828
raise ArgumentError, 'Missing :database configuration.' unless config.has_key?(:database)
29-
when :ado
30-
raise NotImplementedError, 'Please use version 2.3.1 of the adapter for ADO connections. Future versions may support ADO.NET.'
31-
raise ArgumentError, 'Missing :database configuration.' unless config.has_key?(:database)
3229
else
3330
raise ArgumentError, "Unknown connection mode in #{config.inspect}."
3431
end
@@ -169,9 +166,9 @@ class SQLServerAdapter < AbstractAdapter
169166
include Sqlserver::Errors
170167

171168
ADAPTER_NAME = 'SQLServer'.freeze
172-
VERSION = '3.0.0.beta.1'.freeze
169+
VERSION = '3.0.0.rc.1'.freeze
173170
DATABASE_VERSION_REGEXP = /Microsoft SQL Server\s+(\d{4})/
174-
SUPPORTED_VERSIONS = [2000,2005,2008].freeze
171+
SUPPORTED_VERSIONS = [2005,2008].freeze
175172

176173
cattr_accessor :native_text_database_type, :native_binary_database_type, :native_string_database_type,
177174
:log_info_schema_queries, :enable_default_unicode_types, :auto_connect
@@ -273,10 +270,6 @@ def sqlserver?
273270
true
274271
end
275272

276-
def sqlserver_2000?
277-
database_year == 2000
278-
end
279-
280273
def sqlserver_2005?
281274
database_year == 2005
282275
end
@@ -302,12 +295,7 @@ def native_string_database_type
302295
end
303296

304297
def native_text_database_type
305-
@@native_text_database_type ||
306-
if sqlserver_2005? || sqlserver_2008?
307-
enable_default_unicode_types ? 'nvarchar(max)' : 'varchar(max)'
308-
else
309-
enable_default_unicode_types ? 'ntext' : 'text'
310-
end
298+
@@native_text_database_type || enable_default_unicode_types ? 'nvarchar(max)' : 'varchar(max)'
311299
end
312300

313301
def native_time_database_type
@@ -319,7 +307,7 @@ def native_date_database_type
319307
end
320308

321309
def native_binary_database_type
322-
@@native_binary_database_type || ((sqlserver_2005? || sqlserver_2008?) ? 'varbinary(max)' : 'image')
310+
@@native_binary_database_type || 'varbinary(max)'
323311
end
324312

325313

test/cases/adapter_test_sqlserver.rb

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def setup
5757
setup do
5858
@version_regexp = ActiveRecord::ConnectionAdapters::SQLServerAdapter::DATABASE_VERSION_REGEXP
5959
@supported_version = ActiveRecord::ConnectionAdapters::SQLServerAdapter::SUPPORTED_VERSIONS
60-
@sqlserver_2000_string = "Microsoft SQL Server 2000 - 8.00.2039 (Intel X86)"
6160
@sqlserver_2005_string = "Microsoft SQL Server 2005 - 9.00.3215.00 (Intel X86)"
6261
@sqlserver_2008_string = "Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86)"
6362
end
@@ -71,11 +70,6 @@ def setup
7170
assert_contains @supported_version, @connection.database_year
7271
end
7372

74-
should 'return true to #sqlserver_2000?' do
75-
@connection.stubs(:database_version).returns(@sqlserver_2000_string)
76-
assert @connection.sqlserver_2000?
77-
end
78-
7973
should 'return true to #sqlserver_2005?' do
8074
@connection.stubs(:database_version).returns(@sqlserver_2005_string)
8175
assert @connection.sqlserver_2005?
@@ -167,25 +161,15 @@ def setup
167161

168162
should 'use non-unicode types when set to false' do
169163
with_enable_default_unicode_types(false) do
170-
if sqlserver_2000?
171-
assert_equal 'varchar', @connection.native_string_database_type
172-
assert_equal 'text', @connection.native_text_database_type
173-
elsif sqlserver_2005?
174-
assert_equal 'varchar', @connection.native_string_database_type
175-
assert_equal 'varchar(max)', @connection.native_text_database_type
176-
end
164+
assert_equal 'varchar', @connection.native_string_database_type
165+
assert_equal 'varchar(max)', @connection.native_text_database_type
177166
end
178167
end
179168

180169
should 'use unicode types when set to true' do
181170
with_enable_default_unicode_types(true) do
182-
if sqlserver_2000?
183-
assert_equal 'nvarchar', @connection.native_string_database_type
184-
assert_equal 'ntext', @connection.native_text_database_type
185-
elsif sqlserver_2005?
186-
assert_equal 'nvarchar', @connection.native_string_database_type
187-
assert_equal 'nvarchar(max)', @connection.native_text_database_type
188-
end
171+
assert_equal 'nvarchar', @connection.native_string_database_type
172+
assert_equal 'nvarchar(max)', @connection.native_text_database_type
189173
end
190174
end
191175

@@ -409,7 +393,7 @@ def setup
409393
assert @dirty_t2, 'Should have a Task record from within block above.'
410394
assert @dirty_t2.starting, 'Should have a dirty date.'
411395
assert_nil Task.find(@t2.id).starting, 'Should be nil again from botched transaction above.'
412-
end unless active_record_2_point_2? # Transactions in tests are a bit screwy in 2.2.
396+
end
413397

414398
end
415399

test/cases/column_test_sqlserver.rb

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,22 @@ def setup
6868
should 'have correct simplified types' do
6969
assert_equal :string, @char.type
7070
assert_equal :string, @char10.type
71-
if sqlserver_2005? || sqlserver_2008?
72-
assert_equal :text, @varcharmax.type, @varcharmax.inspect
73-
assert_equal :text, @varcharmax10.type, @varcharmax10.inspect
74-
end
71+
assert_equal :text, @varcharmax.type, @varcharmax.inspect
72+
assert_equal :text, @varcharmax10.type, @varcharmax10.inspect
7573
end
7674

7775
should 'have correct #sql_type per schema definition' do
7876
assert_equal 'char(1)', @char.sql_type, 'Specifing a char type with no limit is 1 by SQL Server standards.'
7977
assert_equal 'char(10)', @char10.sql_type, @char10.inspect
80-
if sqlserver_2005? || sqlserver_2008?
81-
assert_equal 'varchar(max)', @varcharmax.sql_type, 'A -1 limit should be converted to max (max) type.'
82-
assert_equal 'varchar(max)', @varcharmax10.sql_type, 'A -1 limit should be converted to max (max) type.'
83-
end
78+
assert_equal 'varchar(max)', @varcharmax.sql_type, 'A -1 limit should be converted to max (max) type.'
79+
assert_equal 'varchar(max)', @varcharmax10.sql_type, 'A -1 limit should be converted to max (max) type.'
8480
end
8581

8682
should 'have correct #limit per schema definition' do
8783
assert_equal 1, @char.limit
8884
assert_equal 10, @char10.limit
89-
if sqlserver_2005? || sqlserver_2008?
90-
assert_equal nil, @varcharmax.limit, 'Limits on max types are moot and we should let rails know that.'
91-
assert_equal nil, @varcharmax10.limit, 'Limits on max types are moot and we should let rails know that.'
92-
end
85+
assert_equal nil, @varcharmax.limit, 'Limits on max types are moot and we should let rails know that.'
86+
assert_equal nil, @varcharmax10.limit, 'Limits on max types are moot and we should let rails know that.'
9387
end
9488

9589
end
@@ -121,10 +115,8 @@ def setup
121115
assert_equal :text, @ntext10.type
122116
assert_equal :string, @nchar10.type
123117
assert_equal :string, @nvarchar100.type
124-
if sqlserver_2005? || sqlserver_2008?
125-
assert_equal :text, @nvarcharmax.type, @nvarcharmax.inspect
126-
assert_equal :text, @nvarcharmax10.type, @nvarcharmax10.inspect
127-
end
118+
assert_equal :text, @nvarcharmax.type, @nvarcharmax.inspect
119+
assert_equal :text, @nvarcharmax10.type, @nvarcharmax10.inspect
128120
end
129121

130122
should 'have correct #sql_type per schema definition' do
@@ -134,10 +126,8 @@ def setup
134126
assert_equal 'ntext', @ntext10.sql_type, 'Even a next with a limit of 10 specified will mean nothing.'
135127
assert_equal 'nchar(10)', @nchar10.sql_type, 'An nchar with a limit of 10 needs to have it show up here.'
136128
assert_equal 'nvarchar(100)', @nvarchar100.sql_type, 'An nvarchar with a specified limit of 100 needs to show it.'
137-
if sqlserver_2005? || sqlserver_2008?
138-
assert_equal 'nvarchar(max)', @nvarcharmax.sql_type, 'A -1 limit should be converted to max (max) type.'
139-
assert_equal 'nvarchar(max)', @nvarcharmax10.sql_type, 'A -1 limit should be converted to max (max) type.'
140-
end
129+
assert_equal 'nvarchar(max)', @nvarcharmax.sql_type, 'A -1 limit should be converted to max (max) type.'
130+
assert_equal 'nvarchar(max)', @nvarcharmax10.sql_type, 'A -1 limit should be converted to max (max) type.'
141131
end
142132

143133
should 'have correct #limit per schema definition' do
@@ -146,10 +136,8 @@ def setup
146136
assert_equal nil, @ntext.limit, 'An ntext column limit is moot, it is a fixed variable length'
147137
assert_equal 10, @nchar10.limit
148138
assert_equal 100, @nvarchar100.limit
149-
if sqlserver_2005? || sqlserver_2008?
150-
assert_equal nil, @nvarcharmax.limit, 'Limits on max types are moot and we should let rails know that.'
151-
assert_equal nil, @nvarcharmax10.limit, 'Limits on max types are moot and we should let rails know that.'
152-
end
139+
assert_equal nil, @nvarcharmax.limit, 'Limits on max types are moot and we should let rails know that.'
140+
assert_equal nil, @nvarcharmax10.limit, 'Limits on max types are moot and we should let rails know that.'
153141
end
154142

155143
end
@@ -169,7 +157,7 @@ def setup
169157

170158
should 'use correct #sql_type for different sql server versions' do
171159
assert_equal 'datetime', @datetime.sql_type
172-
if sqlserver_2000? || sqlserver_2005?
160+
if sqlserver_2005?
173161
assert_equal 'datetime', @date.sql_type
174162
assert_equal 'datetime', @time.sql_type
175163
else

test/cases/execute_procedure_test_sqlserver.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ def setup
2323
should 'quote bind vars correctly' do
2424
assert_sql(/EXEC sp_tables '%sql_server%', NULL, NULL, NULL, 1/) do
2525
@klass.execute_procedure :sp_tables, '%sql_server%', nil, nil, nil, true
26-
end if sqlserver_2005? || sqlserver_2008?
27-
assert_sql(/EXEC sp_tables '%sql_server%', NULL, NULL, NULL/) do
28-
@klass.execute_procedure :sp_tables, '%sql_server%', nil, nil, nil
29-
end if sqlserver_2000?
26+
end
3027
end
3128

3229
should 'allow multiple result sets to be returned' do

test/cases/pessimistic_locking_test_sqlserver.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def setup
8989
first, second = duel(zzz) { Person.find 1, :lock => true }
9090
second.end > first.end
9191
}
92-
end if RUBY_VERSION < '1.9'
92+
end unless ruby_19?
9393

9494
end
9595

test/cases/schema_dumper_test_sqlserver.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class SchemaDumperTestSqlserver < ActiveRecord::TestCase
4141
table_dump('sql_server_strings') do |output|
4242
assert_match %r{t.text.*varchar_max}, output
4343
end
44-
end if sqlserver_2005? || sqlserver_2008?
44+
end
4545

4646
end
4747

test/cases/sqlserver_helper.rb

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,6 @@ def method_added(method)
7272
ActiveRecord::ConnectionAdapters::SQLServerAdapter.enable_default_unicode_types = true
7373
end
7474

75-
# Change the text database type to support ActiveRecord's tests for = on text columns which
76-
# is not supported in SQL Server text columns, so use varchar(8000) instead.
77-
78-
if ActiveRecord::Base.connection.sqlserver_2000?
79-
if ActiveRecord::ConnectionAdapters::SQLServerAdapter.enable_default_unicode_types
80-
ActiveRecord::ConnectionAdapters::SQLServerAdapter.native_text_database_type = 'nvarchar(4000)'
81-
else
82-
ActiveRecord::ConnectionAdapters::SQLServerAdapter.native_text_database_type = 'varchar(8000)'
83-
end
84-
end
85-
8675
# Our changes/additions to ActiveRecord test helpers specific for SQL Server.
8776

8877
ActiveRecord::Base.connection.class.class_eval do
@@ -102,11 +91,8 @@ def raw_select_with_query_record(sql, name = nil)
10291
module ActiveRecord
10392
class TestCase < ActiveSupport::TestCase
10493
class << self
105-
def sqlserver_2000? ; ActiveRecord::Base.connection.sqlserver_2000? ; end
10694
def sqlserver_2005? ; ActiveRecord::Base.connection.sqlserver_2005? ; end
10795
def sqlserver_2008? ; ActiveRecord::Base.connection.sqlserver_2008? ; end
108-
def active_record_2_point_2? ; ActiveRecord::VERSION::MAJOR == 2 && ActiveRecord::VERSION::MINOR == 2 ; end
109-
def active_record_2_point_3? ; ActiveRecord::VERSION::MAJOR == 2 && ActiveRecord::VERSION::MINOR == 3 ; end
11096
def ruby_19? ; RUBY_VERSION >= '1.9' ; end
11197
end
11298
def assert_sql(*patterns_to_match)
@@ -119,11 +105,8 @@ def assert_sql(*patterns_to_match)
119105
end
120106
assert failed_patterns.empty?, "Query pattern(s) #{failed_patterns.map(&:inspect).join(', ')} not found in:\n#{$queries_executed.inspect}"
121107
end
122-
def sqlserver_2000? ; self.class.sqlserver_2000? ; end
123108
def sqlserver_2005? ; self.class.sqlserver_2005? ; end
124109
def sqlserver_2008? ; self.class.sqlserver_2008? ; end
125-
def active_record_2_point_2? ; self.class.active_record_2_point_2? ; end
126-
def active_record_2_point_3? ; self.class.active_record_2_point_3? ; end
127110
def ruby_19? ; self.class.ruby_19? ; end
128111
end
129112
end

test/cases/transaction_test_sqlserver.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class TransactionTestSqlserver < ActiveRecord::TestCase
7575
assert_equal 0, Ship.connection.open_transactions
7676
end
7777

78-
end unless active_record_2_point_2?
78+
end
7979

8080

8181

0 commit comments

Comments
 (0)