tiny_tds 2.1.7-x64-mingw32 → 3.0.0-x64-mingw32

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