tiny_tds 3.0.0-x64-mingw32 → 3.2.0-x64-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +194 -74
  3. data/CHANGELOG.md +12 -0
  4. data/Gemfile +1 -1
  5. data/README.md +59 -50
  6. data/Rakefile +46 -37
  7. data/VERSION +1 -1
  8. data/ext/tiny_tds/extconf.rb +169 -70
  9. data/ext/tiny_tds/extconsts.rb +3 -4
  10. data/lib/tiny_tds/2.7/tiny_tds.so +0 -0
  11. data/lib/tiny_tds/3.0/tiny_tds.so +0 -0
  12. data/lib/tiny_tds/bin.rb +12 -26
  13. data/lib/tiny_tds/client.rb +38 -42
  14. data/lib/tiny_tds/error.rb +0 -2
  15. data/lib/tiny_tds/gem.rb +5 -9
  16. data/lib/tiny_tds/result.rb +0 -2
  17. data/lib/tiny_tds/version.rb +1 -1
  18. data/lib/tiny_tds.rb +28 -47
  19. data/ports/x64-mingw32/{freetds/1.4.23/bin → bin}/defncopy.exe +0 -0
  20. data/ports/x64-mingw32/bin/libsybdb-5.dll +0 -0
  21. data/ports/x64-mingw32/bin/tsql.exe +0 -0
  22. data/tasks/native_gem.rake +11 -18
  23. data/tasks/package.rake +1 -3
  24. data/tasks/ports.rake +7 -91
  25. data/tasks/test.rake +3 -5
  26. data/test/bin/install-freetds.sh +2 -4
  27. data/test/bin/restore-from-native-gem.ps1 +10 -0
  28. data/test/client_test.rb +106 -112
  29. data/test/gem_test.rb +32 -108
  30. data/test/result_test.rb +208 -221
  31. data/test/schema_test.rb +177 -181
  32. data/test/test_helper.rb +59 -64
  33. data/test/thread_test.rb +22 -31
  34. data/tiny_tds.gemspec +28 -29
  35. metadata +27 -43
  36. data/ports/x64-mingw32/freetds/1.4.23/bin/bsqldb.exe +0 -0
  37. data/ports/x64-mingw32/freetds/1.4.23/bin/datacopy.exe +0 -0
  38. data/ports/x64-mingw32/freetds/1.4.23/bin/freebcp.exe +0 -0
  39. data/ports/x64-mingw32/freetds/1.4.23/bin/libct-4.dll +0 -0
  40. data/ports/x64-mingw32/freetds/1.4.23/bin/libsybdb-5.dll +0 -0
  41. data/ports/x64-mingw32/freetds/1.4.23/bin/osql +0 -393
  42. data/ports/x64-mingw32/freetds/1.4.23/bin/tdspool.exe +0 -0
  43. data/ports/x64-mingw32/freetds/1.4.23/bin/tsql.exe +0 -0
  44. data/ports/x64-mingw32/freetds/1.4.23/lib/libct.dll.a +0 -0
  45. data/ports/x64-mingw32/freetds/1.4.23/lib/libct.la +0 -41
  46. data/ports/x64-mingw32/freetds/1.4.23/lib/libsybdb.dll.a +0 -0
  47. data/ports/x64-mingw32/freetds/1.4.23/lib/libsybdb.la +0 -41
  48. data/ports/x64-mingw32/libiconv/1.17/bin/iconv.exe +0 -0
  49. data/ports/x64-mingw32/libiconv/1.17/bin/libcharset-1.dll +0 -0
  50. data/ports/x64-mingw32/libiconv/1.17/bin/libiconv-2.dll +0 -0
  51. data/ports/x64-mingw32/libiconv/1.17/lib/libcharset.dll.a +0 -0
  52. data/ports/x64-mingw32/libiconv/1.17/lib/libcharset.la +0 -41
  53. data/ports/x64-mingw32/libiconv/1.17/lib/libiconv.dll.a +0 -0
  54. data/ports/x64-mingw32/libiconv/1.17/lib/libiconv.la +0 -41
  55. data/ports/x64-mingw32/openssl/3.4.0/bin/c_rehash +0 -252
  56. data/ports/x64-mingw32/openssl/3.4.0/bin/libcrypto-3-x64.dll +0 -0
  57. data/ports/x64-mingw32/openssl/3.4.0/bin/libssl-3-x64.dll +0 -0
  58. data/ports/x64-mingw32/openssl/3.4.0/bin/openssl.exe +0 -0
  59. data/tasks/ports/freetds.rb +0 -32
  60. data/tasks/ports/libiconv.rb +0 -26
  61. data/tasks/ports/openssl.rb +0 -62
  62. data/tasks/ports/recipe.rb +0 -64
  63. data/test/benchmark/query.rb +0 -77
  64. data/test/benchmark/query_odbc.rb +0 -106
  65. data/test/benchmark/query_tinytds.rb +0 -126
data/test/schema_test.rb CHANGED
@@ -1,54 +1,51 @@
1
- # encoding: utf-8
2
- require 'test_helper'
1
+ require "test_helper"
3
2
 
4
3
  class SchemaTest < TinyTds::TestCase
5
-
6
- describe 'Casting SQL Server schema' do
7
-
4
+ describe "Casting SQL Server schema" do
8
5
  before do
9
6
  @@current_schema_loaded ||= load_current_schema
10
7
  @client = new_connection
11
- @gif1px = File.read('test/schema/1px.gif', :mode => "rb:BINARY")
8
+ @gif1px = File.read("test/schema/1px.gif", mode: "rb:BINARY")
12
9
  end
13
10
 
14
- it 'casts bigint' do
15
- assert_equal (-9223372036854775807), find_value(11, :bigint)
11
+ it "casts bigint" do
12
+ assert_equal(-9223372036854775807, find_value(11, :bigint))
16
13
  assert_equal 9223372036854775806, find_value(12, :bigint)
17
14
  end
18
15
 
19
- it 'casts binary' do
16
+ it "casts binary" do
20
17
  value = find_value(21, :binary_50)
21
18
  assert_equal @gif1px + "\000", value
22
19
  assert_binary_encoding(value)
23
20
  end
24
21
 
25
- it 'casts bit' do
22
+ it "casts bit" do
26
23
  assert_equal true, find_value(31, :bit)
27
24
  assert_equal false, find_value(32, :bit)
28
25
  assert_nil find_value(21, :bit)
29
26
  end
30
27
 
31
- it 'casts char' do
32
- partial_char = '12345678 '
33
- assert_equal '1234567890', find_value(41, :char_10)
28
+ it "casts char" do
29
+ partial_char = "12345678 "
30
+ assert_equal "1234567890", find_value(41, :char_10)
34
31
  assert_equal partial_char, find_value(42, :char_10)
35
32
  assert_utf8_encoding find_value(42, :char_10)
36
33
  end
37
34
 
38
- it 'casts datetime' do
35
+ it "casts datetime" do
39
36
  # 1753-01-01T00:00:00.000
40
37
  v = find_value 61, :datetime
41
- assert_instance_of Time, v, 'not in range of Time class'
38
+ assert_instance_of Time, v, "not in range of Time class"
42
39
  assert_equal 1753, v.year
43
- assert_equal 01, v.month
44
- assert_equal 01, v.day
40
+ assert_equal 0o1, v.month
41
+ assert_equal 0o1, v.day
45
42
  assert_equal 0, v.hour
46
43
  assert_equal 0, v.min
47
44
  assert_equal 0, v.sec
48
45
  assert_equal 0, v.usec
49
46
  # 9999-12-31T23:59:59.997
50
47
  v = find_value 62, :datetime
51
- assert_instance_of Time, v, 'not in range of Time class'
48
+ assert_instance_of Time, v, "not in range of Time class"
52
49
  assert_equal 9999, v.year
53
50
  assert_equal 12, v.month
54
51
  assert_equal 31, v.day
@@ -56,64 +53,64 @@ class SchemaTest < TinyTds::TestCase
56
53
  assert_equal 59, v.min
57
54
  assert_equal 59, v.sec
58
55
  assert_equal 997000, v.usec
59
- assert_equal utc_offset, find_value(62, :datetime, :timezone => :local).utc_offset
60
- assert_equal 0, find_value(62, :datetime, :timezone => :utc).utc_offset
56
+ assert_equal utc_offset, find_value(62, :datetime, timezone: :local).utc_offset
57
+ assert_equal 0, find_value(62, :datetime, timezone: :utc).utc_offset
61
58
  # 2010-01-01T12:34:56.123
62
59
  v = find_value 63, :datetime
63
- assert_instance_of Time, v, 'in range of Time class'
60
+ assert_instance_of Time, v, "in range of Time class"
64
61
  assert_equal 2010, v.year
65
- assert_equal 01, v.month
66
- assert_equal 01, v.day
62
+ assert_equal 0o1, v.month
63
+ assert_equal 0o1, v.day
67
64
  assert_equal 12, v.hour
68
65
  assert_equal 34, v.min
69
66
  assert_equal 56, v.sec
70
67
  assert_equal 123000, v.usec
71
- assert_equal utc_offset, find_value(63, :datetime, :timezone => :local).utc_offset
72
- assert_equal 0, find_value(63, :datetime, :timezone => :utc).utc_offset
68
+ assert_equal utc_offset, find_value(63, :datetime, timezone: :local).utc_offset
69
+ assert_equal 0, find_value(63, :datetime, timezone: :utc).utc_offset
73
70
  end
74
71
 
75
- it 'casts decimal' do
72
+ it "casts decimal" do
76
73
  assert_instance_of BigDecimal, find_value(91, :decimal_9_2)
77
- assert_equal BigDecimal('12345.01'), find_value(91, :decimal_9_2)
78
- assert_equal BigDecimal('1234567.89'), find_value(92, :decimal_9_2)
79
- assert_equal BigDecimal('0.0'), find_value(93, :decimal_16_4)
80
- assert_equal BigDecimal('123456789012.3456'), find_value(94, :decimal_16_4)
74
+ assert_equal BigDecimal("12345.01"), find_value(91, :decimal_9_2)
75
+ assert_equal BigDecimal("1234567.89"), find_value(92, :decimal_9_2)
76
+ assert_equal BigDecimal("0.0"), find_value(93, :decimal_16_4)
77
+ assert_equal BigDecimal("123456789012.3456"), find_value(94, :decimal_16_4)
81
78
  end
82
79
 
83
- it 'casts float' do
80
+ it "casts float" do
84
81
  assert_equal 123.00000001, find_value(101, :float)
85
82
  assert_equal 0.0, find_value(102, :float)
86
- assert_equal find_value(102, :float).object_id, find_value(102, :float).object_id, 'use global zero float'
83
+ assert_equal find_value(102, :float).object_id, find_value(102, :float).object_id, "use global zero float"
87
84
  assert_equal 123.45, find_value(103, :float)
88
85
  end
89
86
 
90
- it 'casts image' do
87
+ it "casts image" do
91
88
  value = find_value(141, :image)
92
89
  assert_equal @gif1px, value
93
90
  assert_binary_encoding(value)
94
91
  end
95
92
 
96
- it 'casts int' do
97
- assert_equal (-2147483647), find_value(151, :int)
93
+ it "casts int" do
94
+ assert_equal(-2147483647, find_value(151, :int))
98
95
  assert_equal 2147483646, find_value(152, :int)
99
96
  end
100
97
 
101
- it 'casts money' do
98
+ it "casts money" do
102
99
  assert_instance_of BigDecimal, find_value(161, :money)
103
- assert_equal BigDecimal('4.20'), find_value(161, :money)
104
- assert_equal BigDecimal('922337203685477.5806'), find_value(163, :money)
105
- assert_equal BigDecimal('-922337203685477.5807'), find_value(162, :money)
100
+ assert_equal BigDecimal("4.20"), find_value(161, :money)
101
+ assert_equal BigDecimal("922337203685477.5806"), find_value(163, :money)
102
+ assert_equal BigDecimal("-922337203685477.5807"), find_value(162, :money)
106
103
  end
107
104
 
108
- it 'casts nchar' do
109
- assert_equal '1234567890', find_value(171, :nchar_10)
110
- assert_equal '123456åå ', find_value(172, :nchar_10)
111
- assert_equal 'abc123 ', find_value(173, :nchar_10)
105
+ it "casts nchar" do
106
+ assert_equal "1234567890", find_value(171, :nchar_10)
107
+ assert_equal "123456åå ", find_value(172, :nchar_10)
108
+ assert_equal "abc123 ", find_value(173, :nchar_10)
112
109
  end
113
110
 
114
- it 'casts ntext' do
115
- assert_equal 'test ntext', find_value(181, :ntext)
116
- assert_equal 'test ntext åå', find_value(182, :ntext)
111
+ it "casts ntext" do
112
+ assert_equal "test ntext", find_value(181, :ntext)
113
+ assert_equal "test ntext åå", find_value(182, :ntext)
117
114
  assert_utf8_encoding find_value(182, :ntext)
118
115
  # If this test fails, try setting the "text size" in your freetds.conf. See: http://www.freetds.org/faq.html#textdata
119
116
  large_value = "x" * 5000
@@ -121,284 +118,284 @@ class SchemaTest < TinyTds::TestCase
121
118
  assert_equal large_value, find_value(large_value_id, :ntext)
122
119
  end
123
120
 
124
- it 'casts numeric' do
121
+ it "casts numeric" do
125
122
  assert_instance_of BigDecimal, find_value(191, :numeric_18_0)
126
- assert_equal BigDecimal('191'), find_value(191, :numeric_18_0)
127
- assert_equal BigDecimal('123456789012345678'), find_value(192, :numeric_18_0)
128
- assert_equal BigDecimal('12345678901234567890.01'), find_value(193, :numeric_36_2)
129
- assert_equal BigDecimal('123.46'), find_value(194, :numeric_36_2)
123
+ assert_equal BigDecimal("191"), find_value(191, :numeric_18_0)
124
+ assert_equal BigDecimal("123456789012345678"), find_value(192, :numeric_18_0)
125
+ assert_equal BigDecimal("12345678901234567890.01"), find_value(193, :numeric_36_2)
126
+ assert_equal BigDecimal("123.46"), find_value(194, :numeric_36_2)
130
127
  end
131
128
 
132
- it 'casts nvarchar' do
133
- assert_equal 'test nvarchar_50', find_value(201, :nvarchar_50)
134
- assert_equal 'test nvarchar_50 åå', find_value(202, :nvarchar_50)
129
+ it "casts nvarchar" do
130
+ assert_equal "test nvarchar_50", find_value(201, :nvarchar_50)
131
+ assert_equal "test nvarchar_50 åå", find_value(202, :nvarchar_50)
135
132
  assert_utf8_encoding find_value(202, :nvarchar_50)
136
133
  end
137
134
 
138
- it 'casts real' do
135
+ it "casts real" do
139
136
  assert_in_delta 123.45, find_value(221, :real), 0.01
140
137
  assert_equal 0.0, find_value(222, :real)
141
- assert_equal find_value(222, :real).object_id, find_value(222, :real).object_id, 'use global zero float'
138
+ assert_equal find_value(222, :real).object_id, find_value(222, :real).object_id, "use global zero float"
142
139
  assert_in_delta 0.00001, find_value(223, :real), 0.000001
143
140
  end
144
141
 
145
- it 'casts smalldatetime' do
142
+ it "casts smalldatetime" do
146
143
  # 1901-01-01 15:45:00
147
144
  v = find_value 231, :smalldatetime
148
145
  assert_instance_of Time, v
149
146
  assert_equal 1901, v.year
150
- assert_equal 01, v.month
151
- assert_equal 01, v.day
147
+ assert_equal 0o1, v.month
148
+ assert_equal 0o1, v.day
152
149
  assert_equal 15, v.hour
153
150
  assert_equal 45, v.min
154
- assert_equal 00, v.sec
155
- assert_equal Time.local(1901).utc_offset, find_value(231, :smalldatetime, :timezone => :local).utc_offset
156
- assert_equal 0, find_value(231, :smalldatetime, :timezone => :utc).utc_offset
151
+ assert_equal 0o0, v.sec
152
+ assert_equal Time.local(1901).utc_offset, find_value(231, :smalldatetime, timezone: :local).utc_offset
153
+ assert_equal 0, find_value(231, :smalldatetime, timezone: :utc).utc_offset
157
154
  # 2078-06-05 04:20:00
158
155
  v = find_value 232, :smalldatetime
159
156
  assert_instance_of Time, v
160
157
  assert_equal 2078, v.year
161
- assert_equal 06, v.month
162
- assert_equal 05, v.day
163
- assert_equal 04, v.hour
158
+ assert_equal 0o6, v.month
159
+ assert_equal 0o5, v.day
160
+ assert_equal 0o4, v.hour
164
161
  assert_equal 20, v.min
165
- assert_equal 00, v.sec
166
- assert_equal Time.local(2078, 6).utc_offset, find_value(232, :smalldatetime, :timezone => :local).utc_offset
167
- assert_equal 0, find_value(232, :smalldatetime, :timezone => :utc).utc_offset
162
+ assert_equal 0o0, v.sec
163
+ assert_equal Time.local(2078, 6).utc_offset, find_value(232, :smalldatetime, timezone: :local).utc_offset
164
+ assert_equal 0, find_value(232, :smalldatetime, timezone: :utc).utc_offset
168
165
  end
169
166
 
170
- it 'casts smallint' do
171
- assert_equal (-32767), find_value(241, :smallint)
167
+ it "casts smallint" do
168
+ assert_equal(-32767, find_value(241, :smallint))
172
169
  assert_equal 32766, find_value(242, :smallint)
173
170
  end
174
171
 
175
- it 'casts smallmoney' do
172
+ it "casts smallmoney" do
176
173
  assert_instance_of BigDecimal, find_value(251, :smallmoney)
177
174
  assert_equal BigDecimal("4.20"), find_value(251, :smallmoney)
178
175
  assert_equal BigDecimal("-214748.3647"), find_value(252, :smallmoney)
179
176
  assert_equal BigDecimal("214748.3646"), find_value(253, :smallmoney)
180
177
  end
181
178
 
182
- it 'casts text' do
183
- assert_equal 'test text', find_value(271, :text)
179
+ it "casts text" do
180
+ assert_equal "test text", find_value(271, :text)
184
181
  assert_utf8_encoding find_value(271, :text)
185
182
  end
186
183
 
187
- it 'casts tinyint' do
184
+ it "casts tinyint" do
188
185
  assert_equal 0, find_value(301, :tinyint)
189
186
  assert_equal 255, find_value(302, :tinyint)
190
187
  end
191
188
 
192
- it 'casts uniqueidentifier' do
189
+ it "casts uniqueidentifier" do
193
190
  assert_match %r|\w{8}-\w{4}-\w{4}-\w{4}-\w{12}|, find_value(311, :uniqueidentifier)
194
191
  assert_utf8_encoding find_value(311, :uniqueidentifier)
195
192
  end
196
193
 
197
- it 'casts varbinary' do
194
+ it "casts varbinary" do
198
195
  value = find_value(321, :varbinary_50)
199
196
  assert_equal @gif1px, value
200
197
  assert_binary_encoding(value)
201
198
  end
202
199
 
203
- it 'casts varchar' do
204
- assert_equal 'test varchar_50', find_value(341, :varchar_50)
200
+ it "casts varchar" do
201
+ assert_equal "test varchar_50", find_value(341, :varchar_50)
205
202
  assert_utf8_encoding find_value(341, :varchar_50)
206
203
  end
207
204
 
208
- it 'casts nvarchar(max)' do
209
- assert_equal 'test nvarchar_max', find_value(211, :nvarchar_max)
210
- assert_equal 'test nvarchar_max åå', find_value(212, :nvarchar_max)
205
+ it "casts nvarchar(max)" do
206
+ assert_equal "test nvarchar_max", find_value(211, :nvarchar_max)
207
+ assert_equal "test nvarchar_max åå", find_value(212, :nvarchar_max)
211
208
  assert_utf8_encoding find_value(212, :nvarchar_max)
212
209
  end
213
210
 
214
- it 'casts varbinary(max)' do
211
+ it "casts varbinary(max)" do
215
212
  value = find_value(331, :varbinary_max)
216
213
  assert_equal @gif1px, value
217
214
  assert_binary_encoding(value)
218
215
  end
219
216
 
220
- it 'casts varchar(max)' do
217
+ it "casts varchar(max)" do
221
218
  value = find_value(351, :varchar_max)
222
- assert_equal 'test varchar_max', value
219
+ assert_equal "test varchar_max", value
223
220
  assert_utf8_encoding(value)
224
221
  end
225
222
 
226
- it 'casts xml' do
223
+ it "casts xml" do
227
224
  value = find_value(361, :xml)
228
- assert_equal '<foo><bar>batz</bar></foo>', value
225
+ assert_equal "<foo><bar>batz</bar></foo>", value
229
226
  assert_utf8_encoding(value)
230
227
  end
231
228
 
232
- it 'casts date' do
229
+ it "casts date" do
233
230
  # 0001-01-01
234
231
  v = find_value 51, :date
235
232
  if @client.tds_73?
236
233
  assert_instance_of Date, v
237
- assert_equal 1, v.year, 'Year'
238
- assert_equal 1, v.month, 'Month'
239
- assert_equal 1, v.day, 'Day'
234
+ assert_equal 1, v.year, "Year"
235
+ assert_equal 1, v.month, "Month"
236
+ assert_equal 1, v.day, "Day"
240
237
  else
241
- assert_equal '0001-01-01', v
238
+ assert_equal "0001-01-01", v
242
239
  end
243
240
  # 9999-12-31
244
241
  v = find_value 52, :date
245
242
  if @client.tds_73?
246
243
  assert_instance_of Date, v
247
- assert_equal 9999, v.year, 'Year'
248
- assert_equal 12, v.month, 'Month'
249
- assert_equal 31, v.day, 'Day'
244
+ assert_equal 9999, v.year, "Year"
245
+ assert_equal 12, v.month, "Month"
246
+ assert_equal 31, v.day, "Day"
250
247
  else
251
- assert_equal '9999-12-31', v
248
+ assert_equal "9999-12-31", v
252
249
  end
253
250
  end
254
251
 
255
- it 'casts time' do
252
+ it "casts time" do
256
253
  # 15:45:00.709714966
257
254
  v = find_value 281, :time_2
258
255
  if @client.tds_73?
259
256
  assert_instance_of Time, v
260
- assert_equal 1900, v.year, 'Year'
261
- assert_equal 1, v.month, 'Month'
262
- assert_equal 1, v.day, 'Day'
263
- assert_equal 15, v.hour, 'Hour'
264
- assert_equal 45, v.min, 'Minute'
265
- assert_equal 0, v.sec, 'Second'
266
- assert_equal 710000, v.usec, 'Microseconds'
267
- assert_equal 710000000, v.nsec, 'Nanoseconds'
257
+ assert_equal 1900, v.year, "Year"
258
+ assert_equal 1, v.month, "Month"
259
+ assert_equal 1, v.day, "Day"
260
+ assert_equal 15, v.hour, "Hour"
261
+ assert_equal 45, v.min, "Minute"
262
+ assert_equal 0, v.sec, "Second"
263
+ assert_equal 710000, v.usec, "Microseconds"
264
+ assert_equal 710000000, v.nsec, "Nanoseconds"
268
265
  else
269
- assert_equal '15:45:00.71', v
266
+ assert_equal "15:45:00.71", v
270
267
  end
271
268
  # 04:20:00.288321545
272
269
  v = find_value 282, :time_2
273
270
  if @client.tds_73?
274
271
  assert_instance_of Time, v
275
- assert_equal 1900, v.year, 'Year'
276
- assert_equal 1, v.month, 'Month'
277
- assert_equal 1, v.day, 'Day'
278
- assert_equal 4, v.hour, 'Hour'
279
- assert_equal 20, v.min, 'Minute'
280
- assert_equal 0, v.sec, 'Second'
281
- assert_equal 290000, v.usec, 'Microseconds'
282
- assert_equal 290000000, v.nsec, 'Nanoseconds'
272
+ assert_equal 1900, v.year, "Year"
273
+ assert_equal 1, v.month, "Month"
274
+ assert_equal 1, v.day, "Day"
275
+ assert_equal 4, v.hour, "Hour"
276
+ assert_equal 20, v.min, "Minute"
277
+ assert_equal 0, v.sec, "Second"
278
+ assert_equal 290000, v.usec, "Microseconds"
279
+ assert_equal 290000000, v.nsec, "Nanoseconds"
283
280
  else
284
- assert_equal '04:20:00.29', v
281
+ assert_equal "04:20:00.29", v
285
282
  end
286
283
  # 15:45:00.709714966
287
284
  v = find_value 283, :time_7
288
285
  if @client.tds_73?
289
286
  assert_instance_of Time, v
290
- assert_equal 1900, v.year, 'Year'
291
- assert_equal 1, v.month, 'Month'
292
- assert_equal 1, v.day, 'Day'
293
- assert_equal 15, v.hour, 'Hour'
294
- assert_equal 45, v.min, 'Minute'
295
- assert_equal 0, v.sec, 'Second'
296
- assert_equal 709715, v.usec, 'Microseconds'
297
- assert_equal 709715000, v.nsec, 'Nanoseconds'
287
+ assert_equal 1900, v.year, "Year"
288
+ assert_equal 1, v.month, "Month"
289
+ assert_equal 1, v.day, "Day"
290
+ assert_equal 15, v.hour, "Hour"
291
+ assert_equal 45, v.min, "Minute"
292
+ assert_equal 0, v.sec, "Second"
293
+ assert_equal 709715, v.usec, "Microseconds"
294
+ assert_equal 709715000, v.nsec, "Nanoseconds"
298
295
  else
299
- assert_equal '15:45:00.7097150', v
296
+ assert_equal "15:45:00.7097150", v
300
297
  end
301
298
  # 04:20:00.288321545
302
299
  v = find_value 284, :time_7
303
300
  if @client.tds_73?
304
301
  assert_instance_of Time, v
305
- assert_equal 1900, v.year, 'Year'
306
- assert_equal 1, v.month, 'Month'
307
- assert_equal 1, v.day, 'Day'
308
- assert_equal 4, v.hour, 'Hour'
309
- assert_equal 20, v.min, 'Minute'
310
- assert_equal 0, v.sec, 'Second'
311
- assert_equal 288321, v.usec, 'Microseconds'
312
- assert_equal 288321500, v.nsec, 'Nanoseconds'
302
+ assert_equal 1900, v.year, "Year"
303
+ assert_equal 1, v.month, "Month"
304
+ assert_equal 1, v.day, "Day"
305
+ assert_equal 4, v.hour, "Hour"
306
+ assert_equal 20, v.min, "Minute"
307
+ assert_equal 0, v.sec, "Second"
308
+ assert_equal 288321, v.usec, "Microseconds"
309
+ assert_equal 288321500, v.nsec, "Nanoseconds"
313
310
  else
314
- assert_equal '04:20:00.2883215', v
311
+ assert_equal "04:20:00.2883215", v
315
312
  end
316
313
  end
317
314
 
318
- it 'casts datetime2' do
315
+ it "casts datetime2" do
319
316
  # 0001-01-01 00:00:00.0000000
320
317
  v = find_value 71, :datetime2_7
321
318
  if @client.tds_73?
322
319
  assert_instance_of Time, v
323
- assert_equal 1, v.year, 'Year'
324
- assert_equal 1, v.month, 'Month'
325
- assert_equal 1, v.day, 'Day'
326
- assert_equal 0, v.hour, 'Hour'
327
- assert_equal 0, v.min, 'Minute'
328
- assert_equal 0, v.sec, 'Second'
329
- assert_equal 0, v.usec, 'Microseconds'
330
- assert_equal 0, v.nsec, 'Nanoseconds'
320
+ assert_equal 1, v.year, "Year"
321
+ assert_equal 1, v.month, "Month"
322
+ assert_equal 1, v.day, "Day"
323
+ assert_equal 0, v.hour, "Hour"
324
+ assert_equal 0, v.min, "Minute"
325
+ assert_equal 0, v.sec, "Second"
326
+ assert_equal 0, v.usec, "Microseconds"
327
+ assert_equal 0, v.nsec, "Nanoseconds"
331
328
  else
332
- assert_equal '0001-01-01 00:00:00.0000000', v
329
+ assert_equal "0001-01-01 00:00:00.0000000", v
333
330
  end
334
331
  # 1984-01-24 04:20:00.0000000
335
332
  v = find_value 72, :datetime2_7
336
333
  if @client.tds_73?
337
334
  assert_instance_of Time, v
338
- assert_equal 1984, v.year, 'Year'
339
- assert_equal 1, v.month, 'Month'
340
- assert_equal 24, v.day, 'Day'
341
- assert_equal 4, v.hour, 'Hour'
342
- assert_equal 20, v.min, 'Minute'
343
- assert_equal 0, v.sec, 'Second'
344
- assert_equal 0, v.usec, 'Microseconds'
345
- assert_equal 0, v.nsec, 'Nanoseconds'
335
+ assert_equal 1984, v.year, "Year"
336
+ assert_equal 1, v.month, "Month"
337
+ assert_equal 24, v.day, "Day"
338
+ assert_equal 4, v.hour, "Hour"
339
+ assert_equal 20, v.min, "Minute"
340
+ assert_equal 0, v.sec, "Second"
341
+ assert_equal 0, v.usec, "Microseconds"
342
+ assert_equal 0, v.nsec, "Nanoseconds"
346
343
  else
347
- assert_equal '1984-01-24 04:20:00.0000000', v
344
+ assert_equal "1984-01-24 04:20:00.0000000", v
348
345
  end
349
346
  # 9999-12-31 23:59:59.9999999
350
347
  v = find_value 73, :datetime2_7
351
348
  if @client.tds_73?
352
349
  assert_instance_of Time, v
353
- assert_equal 9999, v.year, 'Year'
354
- assert_equal 12, v.month, 'Month'
355
- assert_equal 31, v.day, 'Day'
356
- assert_equal 23, v.hour, 'Hour'
357
- assert_equal 59, v.min, 'Minute'
358
- assert_equal 59, v.sec, 'Second'
359
- assert_equal 999999, v.usec, 'Microseconds'
360
- assert_equal 999999900, v.nsec, 'Nanoseconds'
350
+ assert_equal 9999, v.year, "Year"
351
+ assert_equal 12, v.month, "Month"
352
+ assert_equal 31, v.day, "Day"
353
+ assert_equal 23, v.hour, "Hour"
354
+ assert_equal 59, v.min, "Minute"
355
+ assert_equal 59, v.sec, "Second"
356
+ assert_equal 999999, v.usec, "Microseconds"
357
+ assert_equal 999999900, v.nsec, "Nanoseconds"
361
358
  else
362
- assert_equal '9999-12-31 23:59:59.9999999', v
359
+ assert_equal "9999-12-31 23:59:59.9999999", v
363
360
  end
364
361
  # 9999-12-31 23:59:59.123456789
365
362
  v = find_value 74, :datetime2_2
366
363
  if @client.tds_73?
367
364
  assert_instance_of Time, v
368
- assert_equal 9999, v.year, 'Year'
369
- assert_equal 12, v.month, 'Month'
370
- assert_equal 31, v.day, 'Day'
371
- assert_equal 23, v.hour, 'Hour'
372
- assert_equal 59, v.min, 'Minute'
373
- assert_equal 59, v.sec, 'Second'
374
- assert_equal 120000, v.usec, 'Microseconds'
375
- assert_equal 120000000, v.nsec, 'Nanoseconds'
365
+ assert_equal 9999, v.year, "Year"
366
+ assert_equal 12, v.month, "Month"
367
+ assert_equal 31, v.day, "Day"
368
+ assert_equal 23, v.hour, "Hour"
369
+ assert_equal 59, v.min, "Minute"
370
+ assert_equal 59, v.sec, "Second"
371
+ assert_equal 120000, v.usec, "Microseconds"
372
+ assert_equal 120000000, v.nsec, "Nanoseconds"
376
373
  else
377
- assert_equal '9999-12-31 23:59:59.12', v
374
+ assert_equal "9999-12-31 23:59:59.12", v
378
375
  end
379
376
  end
380
377
 
381
- it 'casts datetimeoffset' do
378
+ it "casts datetimeoffset" do
382
379
  # 1984-01-24T04:20:00.1234567-08:00
383
380
  v = find_value 84, :datetimeoffset_7
384
381
  if @client.tds_73?
385
382
  assertions = lambda {
386
383
  assert_instance_of Time, v
387
- assert_equal 1984, v.year, 'Year'
388
- assert_equal 1, v.month, 'Month'
389
- assert_equal 24, v.day, 'Day'
390
- assert_equal 4, v.hour, 'Hour'
391
- assert_equal 20, v.min, 'Minute'
392
- assert_equal 59, v.sec, 'Second'
393
- assert_equal 123456, v.usec, 'Microseconds'
394
- assert_equal 123456700, v.nsec, 'Nanoseconds'
395
- assert_equal (-28800), v.utc_offset, 'Offset'
384
+ assert_equal 1984, v.year, "Year"
385
+ assert_equal 1, v.month, "Month"
386
+ assert_equal 24, v.day, "Day"
387
+ assert_equal 4, v.hour, "Hour"
388
+ assert_equal 20, v.min, "Minute"
389
+ assert_equal 59, v.sec, "Second"
390
+ assert_equal 123456, v.usec, "Microseconds"
391
+ assert_equal 123456700, v.nsec, "Nanoseconds"
392
+ assert_equal(-28800, v.utc_offset, "Offset")
396
393
  }
397
394
  assertions.call
398
395
  v = find_value 84, :datetimeoffset_7, timezone: :local
399
396
  assertions.call # Ignores timezone query option.
400
397
  else
401
- assert_equal '1984-01-24 04:20:59.1234567 -08:00', v
398
+ assert_equal "1984-01-24 04:20:59.1234567 -08:00", v
402
399
  end
403
400
  end
404
401
 
@@ -416,6 +413,5 @@ class SchemaTest < TinyTds::TestCase
416
413
  # value = find_value 131, :hierarchyid
417
414
  # assert_equal '', value
418
415
  # end
419
-
420
416
  end
421
417
  end