activerecord-sqlserver-adapter 2.2.21 → 2.2.22
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -1
- data/README.rdoc +1 -1
- data/Rakefile +1 -1
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +2 -2
- data/lib/active_record/connection_adapters/sqlserver_adapter/core_ext/dbi.rb +10 -0
- data/test/cases/column_test_sqlserver.rb +16 -0
- data/test/cases/specific_schema_test_sqlserver.rb +18 -0
- data/test/cases/table_name_test_sqlserver.rb +16 -0
- data/test/schema/sqlserver_specific_schema.rb +1 -0
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
|
2
2
|
MASTER
|
3
3
|
|
4
|
-
|
4
|
+
|
5
|
+
|
6
|
+
* 2.2.22 * (October 15th, 2009)
|
7
|
+
|
8
|
+
* Support Identity-key-column judgement on multiple schema environment [Ken Tachiya]
|
9
|
+
|
10
|
+
* Add support for tinyint data types. In MySQL all these types would be boolean, however in
|
11
|
+
our adapter, they will use the full 1 => 255 Fixnum value as you would expect. [Ken Collins]
|
5
12
|
|
6
13
|
|
7
14
|
* 2.2.21 * (September 10th, 2009)
|
data/README.rdoc
CHANGED
@@ -130,7 +130,7 @@ It is our goal to match the adapter version with each version of rails. However
|
|
130
130
|
|
131
131
|
First, you will need Ruby DBI and Ruby ODBC. If you are using the adapter under 1.9, then you need at least ruby-odbc version 0.9996. To my knowledge the ADO DBD for DBI is no longer supported. The installation below is not a comprehensive walk thru on how to get all the required moving parts like FreeTDS installed and/or configured. It will also assume gem installations of both the dependent libraries and the adapter itself.
|
132
132
|
|
133
|
-
It should be noted that this version of the adapter was developed using both the ancient 0.0.23 version of DBI up to the current stable release of 0.4.1. Note that DBI 0.4.1 is the minimal for ruby 1.9 compatibility. Because later versions of DBI will be changing many things, IT IS HIGHLY
|
133
|
+
It should be noted that this version of the adapter was developed using both the ancient 0.0.23 version of DBI up to the current stable release of 0.4.1. Note that DBI 0.4.1 is the minimal for ruby 1.9 compatibility. Because later versions of DBI will be changing many things, IT IS HIGHLY NECESSARY that you max your install to version 0.4.1 which the examples below show. For the time being we are not supporting DBI versions higher than 0.4.1 this they settle down on new internal implementations.
|
134
134
|
|
135
135
|
$ gem install dbi --version 0.4.1
|
136
136
|
$ gem install dbd-odbc --version 0.2.4
|
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require 'rake'
|
|
3
3
|
require 'rake/testtask'
|
4
4
|
require 'echoe'
|
5
5
|
|
6
|
-
Echoe.new('activerecord-sqlserver-adapter','2.2.
|
6
|
+
Echoe.new('activerecord-sqlserver-adapter','2.2.22') do |p|
|
7
7
|
p.summary = "SQL Server 2000, 2005 and 2008 Adapter For Rails."
|
8
8
|
p.description = "SQL Server 2000, 2005 and 2008 Adapter For Rails."
|
9
9
|
p.author = ["Ken Collins","Murray Steele","Shawn Balestracci","Joe Rafaniello","Tom Ward"]
|
@@ -183,7 +183,7 @@ module ActiveRecord
|
|
183
183
|
class SQLServerAdapter < AbstractAdapter
|
184
184
|
|
185
185
|
ADAPTER_NAME = 'SQLServer'.freeze
|
186
|
-
VERSION = '2.2.
|
186
|
+
VERSION = '2.2.22'.freeze
|
187
187
|
DATABASE_VERSION_REGEXP = /Microsoft SQL Server\s+(\d{4})/
|
188
188
|
SUPPORTED_VERSIONS = [2000,2005,2008].freeze
|
189
189
|
LIMITABLE_TYPES = ['string','integer','float','char','nchar','varchar','nvarchar'].freeze
|
@@ -1052,7 +1052,7 @@ module ActiveRecord
|
|
1052
1052
|
ELSE NULL
|
1053
1053
|
end as is_nullable,
|
1054
1054
|
CASE
|
1055
|
-
WHEN COLUMNPROPERTY(OBJECT_ID(columns.TABLE_NAME), columns.COLUMN_NAME, 'IsIdentity') = 0 THEN NULL
|
1055
|
+
WHEN COLUMNPROPERTY(OBJECT_ID(columns.TABLE_SCHEMA+'.'+columns.TABLE_NAME), columns.COLUMN_NAME, 'IsIdentity') = 0 THEN NULL
|
1056
1056
|
ELSE 1
|
1057
1057
|
END as is_identity
|
1058
1058
|
FROM #{db_name}INFORMATION_SCHEMA.COLUMNS columns
|
@@ -46,6 +46,14 @@ module ActiveRecord
|
|
46
46
|
obj.to_s
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
# We want our true 1 to 255 tinyint range.
|
51
|
+
class SqlserverForcedTinyint
|
52
|
+
def self.parse(obj)
|
53
|
+
return nil if ::DBI::Type::Null.parse(obj).nil?
|
54
|
+
obj.to_i
|
55
|
+
end
|
56
|
+
end
|
49
57
|
|
50
58
|
end
|
51
59
|
|
@@ -68,6 +76,8 @@ module ActiveRecord
|
|
68
76
|
DBI::Type::SqlserverTimestamp
|
69
77
|
when /^float|decimal|money$/i
|
70
78
|
DBI::Type::SqlserverForcedString
|
79
|
+
when /^tinyint$/i
|
80
|
+
DBI::Type::SqlserverForcedTinyint
|
71
81
|
else
|
72
82
|
type_name_to_module_without_sqlserver_types(type_name)
|
73
83
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'cases/sqlserver_helper'
|
2
2
|
require 'models/binary'
|
3
3
|
|
4
|
+
class SqlServerEdgeSchema < ActiveRecord::Base; end;
|
5
|
+
|
4
6
|
class ColumnTestSqlserver < ActiveRecord::TestCase
|
5
7
|
|
6
8
|
def setup
|
@@ -260,5 +262,19 @@ class ColumnTestSqlserver < ActiveRecord::TestCase
|
|
260
262
|
|
261
263
|
end
|
262
264
|
|
265
|
+
context 'For tinyint columns' do
|
266
|
+
|
267
|
+
setup do
|
268
|
+
@tinyint = SqlServerEdgeSchema.columns_hash['tinyint']
|
269
|
+
end
|
270
|
+
|
271
|
+
should 'be all it should be' do
|
272
|
+
assert_equal :integer, @tinyint.type
|
273
|
+
assert_nil @tinyint.scale
|
274
|
+
assert_equal 'tinyint(1)', @tinyint.sql_type
|
275
|
+
end
|
276
|
+
|
277
|
+
end
|
278
|
+
|
263
279
|
|
264
280
|
end
|
@@ -68,6 +68,24 @@ class SpecificSchemaTestSqlserver < ActiveRecord::TestCase
|
|
68
68
|
|
69
69
|
end
|
70
70
|
|
71
|
+
context 'with tinyint column' do
|
72
|
+
|
73
|
+
setup do
|
74
|
+
@tiny1 = @edge_class.create! :tinyint => 1
|
75
|
+
@tiny255 = @edge_class.create! :tinyint => 255
|
76
|
+
end
|
77
|
+
|
78
|
+
should 'not treat tinyint like boolean as mysql does' do
|
79
|
+
assert_equal 1, @edge_class.find_by_tinyint(1).tinyint
|
80
|
+
assert_equal 255, @edge_class.find_by_tinyint(255).tinyint
|
81
|
+
end
|
82
|
+
|
83
|
+
should 'throw an error when going out of our tiny int bounds' do
|
84
|
+
assert_raise(ActiveRecord::StatementInvalid) { @edge_class.create! :tinyint => 256 }
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
71
89
|
end
|
72
90
|
|
73
91
|
|
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'cases/sqlserver_helper'
|
2
2
|
require 'models/order'
|
3
3
|
|
4
|
+
class SqlServerRailsOrders < ActiveRecord::Base
|
5
|
+
set_table_name 'rails.orders'
|
6
|
+
end
|
7
|
+
|
4
8
|
class TableNameTestSqlserver < ActiveRecord::TestCase
|
5
9
|
|
6
10
|
self.use_transactional_fixtures = false
|
@@ -18,5 +22,17 @@ class TableNameTestSqlserver < ActiveRecord::TestCase
|
|
18
22
|
assert_sql(/SELECT \* FROM \[orders\]/) { Order.all }
|
19
23
|
end
|
20
24
|
|
25
|
+
context 'Table scoped to user.table_name' do
|
26
|
+
|
27
|
+
setup do
|
28
|
+
@klass = SqlServerRailsOrders
|
29
|
+
end
|
30
|
+
|
31
|
+
should 'have no issue doing basic column reflection' do
|
32
|
+
assert_nothing_raised() { @klass.columns }
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
21
37
|
|
22
38
|
end
|
@@ -65,6 +65,7 @@ ActiveRecord::Schema.define do
|
|
65
65
|
create_table :sql_server_edge_schemas, :force => true do |t|
|
66
66
|
t.string :description
|
67
67
|
t.column :bigint, :bigint
|
68
|
+
t.column :tinyint, :tinyint
|
68
69
|
end
|
69
70
|
|
70
71
|
execute "IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = 'customers_view') DROP VIEW customers_view"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-sqlserver-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Collins, Murray Steele, Shawn Balestracci, Joe Rafaniello, Tom Ward
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-15 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|