activerecord-sqlserver-adapter 3.0.3 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,13 @@
1
1
 
2
+ * 3.0.4 *
3
+
4
+ * Add multiple results set support with #execute_procedure for :dblib mode. [Ken Collins]
5
+
6
+ * Simplify encoding support. [Ken Collins]
7
+
8
+ * Add binary timestamp datatype handling. [Erik Bryn]
9
+
10
+
2
11
  * 3.0.3
3
12
 
4
13
  * Add TinyTDS/dblib connection mode. [Ken Collins]
@@ -6,7 +6,8 @@ The SQL Server adapter for ActiveRecord.
6
6
 
7
7
  == What's New
8
8
 
9
- * Version 3.x now supports rails 3!
9
+ * New dblib connection mode using TinyTds!
10
+ * Rails 3 support!
10
11
 
11
12
 
12
13
  ==== Testing Rake Tasks Support
@@ -72,12 +72,17 @@ module ActiveRecord
72
72
  vars = variables.map{ |v| quote(v) }.join(', ')
73
73
  sql = "EXEC #{proc_name} #{vars}".strip
74
74
  name = 'Execute Procedure'
75
- results = []
76
- case @connection_options[:mode]
77
- when :dblib
78
- results << select(sql, name).map { |r| r.with_indifferent_access }
79
- when :odbc
80
- log(sql, name) do
75
+ log(sql, name) do
76
+ case @connection_options[:mode]
77
+ when :dblib
78
+ result = @connection.execute(sql)
79
+ result.each(:as => :hash, :cache_rows => true) do |row|
80
+ r = row.with_indifferent_access
81
+ yield(r) if block_given?
82
+ end
83
+ result.each
84
+ when :odbc
85
+ results = []
81
86
  raw_connection_run(sql) do |handle|
82
87
  get_rows = lambda {
83
88
  rows = handle_to_names_and_values handle, :fetch => :all
@@ -89,11 +94,13 @@ module ActiveRecord
89
94
  get_rows.call
90
95
  end
91
96
  end
97
+ results.many? ? results : results.first
98
+ when :adonet
99
+ results = []
100
+ results << select(sql, name).map { |r| r.with_indifferent_access }
101
+ results.many? ? results : results.first
92
102
  end
93
- when :adonet
94
- results << select(sql, name).map { |r| r.with_indifferent_access }
95
103
  end
96
- results.many? ? results : results.first
97
104
  end
98
105
 
99
106
  def use_database(database=nil)
@@ -10,8 +10,8 @@ module ActiveRecord
10
10
  when String, ActiveSupport::Multibyte::Chars
11
11
  if column && column.type == :binary
12
12
  column.class.string_to_binary(value)
13
- elsif quote_value_as_utf8?(value) || column && column.respond_to?(:is_utf8?) && column.is_utf8?
14
- quoted_utf8_value(value)
13
+ elsif value.is_utf8? || (column && column.type == :string)
14
+ "N'#{quote_string(value)}'"
15
15
  else
16
16
  super
17
17
  end
@@ -48,14 +48,6 @@ module ActiveRecord
48
48
  super
49
49
  end
50
50
  end
51
-
52
- def quoted_utf8_value(value)
53
- "N'#{quote_string(value)}'"
54
- end
55
-
56
- def quote_value_as_utf8?(value)
57
- value.is_utf8? || enable_default_unicode_types
58
- end
59
51
 
60
52
  end
61
53
  end
@@ -168,7 +168,8 @@ module ActiveRecord
168
168
  :nchar => { :name => "nchar" },
169
169
  :nvarchar => { :name => "nvarchar", :limit => 255 },
170
170
  :nvarchar_max => { :name => "nvarchar(max)" },
171
- :ntext => { :name => "ntext" }
171
+ :ntext => { :name => "ntext" },
172
+ :ss_timestamp => { :name => 'timestamp' }
172
173
  })
173
174
  end
174
175
 
@@ -68,38 +68,16 @@ module ActiveRecord
68
68
 
69
69
  class << self
70
70
 
71
- def string_to_utf8_encoding(value)
72
- value.force_encoding('UTF-8') rescue value
73
- end
74
-
75
71
  def string_to_binary(value)
76
- value = value.dup.force_encoding(Encoding::BINARY) if value.respond_to?(:force_encoding)
77
72
  "0x#{value.unpack("H*")[0]}"
78
73
  end
79
74
 
80
75
  def binary_to_string(value)
81
- value = value.dup.force_encoding(Encoding::BINARY) if value.respond_to?(:force_encoding)
82
76
  value =~ /[^[:xdigit:]]/ ? value : [value].pack('H*')
83
77
  end
84
78
 
85
79
  end
86
80
 
87
- def type_cast(value)
88
- if value && type == :string && is_utf8?
89
- self.class.string_to_utf8_encoding(value)
90
- else
91
- super
92
- end
93
- end
94
-
95
- def type_cast_code(var_name)
96
- if type == :string && is_utf8?
97
- "#{self.class.name}.string_to_utf8_encoding(#{var_name})"
98
- else
99
- super
100
- end
101
- end
102
-
103
81
  def is_identity?
104
82
  @sqlserver_options[:is_identity]
105
83
  end
@@ -156,6 +134,7 @@ module ActiveRecord
156
134
  when /uniqueidentifier/i then :string
157
135
  when /datetime/i then simplified_datetime
158
136
  when /varchar\(max\)/ then :text
137
+ when /timestamp/ then :binary
159
138
  else super
160
139
  end
161
140
  end
@@ -184,7 +163,7 @@ module ActiveRecord
184
163
  include Sqlserver::Errors
185
164
 
186
165
  ADAPTER_NAME = 'SQLServer'.freeze
187
- VERSION = '3.0.3'.freeze
166
+ VERSION = '3.0.4'.freeze
188
167
  DATABASE_VERSION_REGEXP = /Microsoft SQL Server\s+(\d{4})/
189
168
  SUPPORTED_VERSIONS = [2005,2008].freeze
190
169
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-sqlserver-adapter
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
- - 3
10
- version: 3.0.3
9
+ - 4
10
+ version: 3.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ken Collins
@@ -19,7 +19,7 @@ autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
21
 
22
- date: 2010-10-17 00:00:00 -04:00
22
+ date: 2010-10-26 00:00:00 -04:00
23
23
  default_executable:
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
@@ -34,7 +34,8 @@ dependencies:
34
34
  segments:
35
35
  - 3
36
36
  - 0
37
- version: "3.0"
37
+ - 0
38
+ version: 3.0.0
38
39
  type: :runtime
39
40
  version_requirements: *id001
40
41
  description: SQL Server 2005 and 2008 Adapter For ActiveRecord