ruby-oci8 1.0.6-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/ChangeLog +693 -0
  2. data/Makefile +51 -0
  3. data/NEWS +407 -0
  4. data/README +415 -0
  5. data/VERSION +1 -0
  6. data/dist-files +71 -0
  7. data/doc/api.en.html +527 -0
  8. data/doc/api.en.rd +554 -0
  9. data/doc/api.ja.html +525 -0
  10. data/doc/api.ja.rd +557 -0
  11. data/doc/manual.css +35 -0
  12. data/ext/oci8/oci8lib.so +0 -0
  13. data/lib/dbd/OCI8.rb +591 -0
  14. data/lib/oci8.rb +1655 -0
  15. data/lib/oci8.rb.in +1655 -0
  16. data/metaconfig +142 -0
  17. data/pre-distclean.rb +7 -0
  18. data/ruby-oci8.gemspec +54 -0
  19. data/ruby-oci8.spec +62 -0
  20. data/setup.rb +1331 -0
  21. data/support/README +4 -0
  22. data/support/runit/assert.rb +281 -0
  23. data/support/runit/cui/testrunner.rb +101 -0
  24. data/support/runit/error.rb +4 -0
  25. data/support/runit/method_mappable.rb +20 -0
  26. data/support/runit/robserver.rb +25 -0
  27. data/support/runit/setuppable.rb +15 -0
  28. data/support/runit/teardownable.rb +16 -0
  29. data/support/runit/testcase.rb +113 -0
  30. data/support/runit/testfailure.rb +25 -0
  31. data/support/runit/testresult.rb +121 -0
  32. data/support/runit/testsuite.rb +43 -0
  33. data/support/runit/version.rb +3 -0
  34. data/test/README +4 -0
  35. data/test/config.rb +129 -0
  36. data/test/test_all.rb +48 -0
  37. data/test/test_bind_raw.rb +53 -0
  38. data/test/test_bind_time.rb +191 -0
  39. data/test/test_break.rb +81 -0
  40. data/test/test_clob.rb +101 -0
  41. data/test/test_connstr.rb +80 -0
  42. data/test/test_dbi.rb +327 -0
  43. data/test/test_dbi_clob.rb +58 -0
  44. data/test/test_describe.rb +137 -0
  45. data/test/test_metadata.rb +243 -0
  46. data/test/test_oci8.rb +273 -0
  47. data/test/test_oradate.rb +263 -0
  48. data/test/test_oranumber.rb +149 -0
  49. data/test/test_rowid.rb +38 -0
  50. metadata +105 -0
@@ -0,0 +1,263 @@
1
+ # Low-level API
2
+ require 'oci8'
3
+ require 'runit/testcase'
4
+ require 'runit/cui/testrunner'
5
+ require File.dirname(__FILE__) + '/config'
6
+
7
+ class TestOraDate < RUNIT::TestCase
8
+
9
+ YEAR_CHECK_TARGET = [-4712, -1, 1, 1192, 1868, 2002, 9999]
10
+ MONTH_CHECK_TARGET = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
11
+ DAY_CHECK_TARGET = [1, 10, 20, 31] # days of January.
12
+ HOUR_CHECK_TARGET = [0, 6, 12, 18, 23]
13
+ MINUTE_CHECK_TARGET = [0, 15, 30, 45, 59]
14
+ SECOND_CHECK_TARGET = [0, 15, 30, 45, 59]
15
+
16
+ def setup
17
+ @env, @svc, @stmt = setup_lowapi()
18
+ end
19
+
20
+ def check_oradate(target, year, month, day, hour, minute, second)
21
+ assert_equal(year, target.year)
22
+ assert_equal(month, target.month)
23
+ assert_equal(day, target.day)
24
+ assert_equal(hour, target.hour)
25
+ assert_equal(minute, target.minute)
26
+ assert_equal(second, target.second)
27
+ end
28
+
29
+ def test_new()
30
+ check_oradate(OraDate.new(), 1, 1, 1, 0, 0, 0)
31
+ end
32
+
33
+ def test_set_year
34
+ @stmt.prepare("BEGIN :year := TO_NUMBER(TO_CHAR(:date, 'SYYYY'), '9999'); END;")
35
+ date_in = @stmt.bindByName(":date", OraDate)
36
+ year_out = @stmt.bindByName(":year", Fixnum)
37
+ date = OraDate.new()
38
+ YEAR_CHECK_TARGET.each do |i|
39
+ # set year
40
+ date.year = i
41
+ # check result via oracle.
42
+ date_in.set(date)
43
+ @stmt.execute(@svc)
44
+ assert_equal(i, year_out.get())
45
+ end
46
+ end
47
+
48
+ def test_get_year
49
+ @stmt.prepare("BEGIN :date := TO_DATE(TO_CHAR(:year, '0999'), 'SYYYY'); END;")
50
+ year_in = @stmt.bindByName(":year", Fixnum)
51
+ date_out = @stmt.bindByName(":date", OraDate)
52
+ YEAR_CHECK_TARGET.each do |i|
53
+ # set date via oracle.
54
+ year_in.set(i)
55
+ @stmt.execute(@svc)
56
+ # check OraDate#year
57
+ assert_equal(i, date_out.get.year)
58
+ end
59
+ end
60
+
61
+ def test_set_month
62
+ @stmt.prepare("BEGIN :month := TO_NUMBER(TO_CHAR(:date, 'MM'), '99'); END;")
63
+ date_in = @stmt.bindByName(":date", OraDate)
64
+ month_out = @stmt.bindByName(":month", Fixnum)
65
+ date = OraDate.new()
66
+ MONTH_CHECK_TARGET.each do |i|
67
+ # set month
68
+ date.month = i
69
+ # check result via oracle.
70
+ date_in.set(date)
71
+ @stmt.execute(@svc)
72
+ assert_equal(i, month_out.get())
73
+ end
74
+ end
75
+
76
+ def test_get_month
77
+ @stmt.prepare("BEGIN :date := TO_DATE(TO_CHAR(:month, '99'), 'MM'); END;")
78
+ month_in = @stmt.bindByName(":month", Fixnum)
79
+ date_out = @stmt.bindByName(":date", OraDate)
80
+ MONTH_CHECK_TARGET.each do |i|
81
+ # set date via oracle.
82
+ month_in.set(i)
83
+ @stmt.execute(@svc)
84
+ # check OraDate#month
85
+ assert_equal(i, date_out.get.month)
86
+ end
87
+ end
88
+
89
+ def test_set_day
90
+ @stmt.prepare("BEGIN :day := TO_NUMBER(TO_CHAR(:date, 'DD'), '99'); END;")
91
+ date_in = @stmt.bindByName(":date", OraDate)
92
+ day_out = @stmt.bindByName(":day", Fixnum)
93
+ date = OraDate.new()
94
+ DAY_CHECK_TARGET.each do |i|
95
+ # set day
96
+ date.day = i
97
+ # check result via oracle.
98
+ date_in.set(date)
99
+ @stmt.execute(@svc)
100
+ assert_equal(i, day_out.get())
101
+ end
102
+ end
103
+
104
+ def test_get_day
105
+ @stmt.prepare("BEGIN :date := TO_DATE('200101' || TO_CHAR(:day, 'FM00'), 'YYYYMMDD'); END;")
106
+ day_in = @stmt.bindByName(":day", Fixnum)
107
+ date_out = @stmt.bindByName(":date", OraDate)
108
+ DAY_CHECK_TARGET.each do |i|
109
+ # set date via oracle.
110
+ day_in.set(i)
111
+ @stmt.execute(@svc)
112
+ # check OraDate#day
113
+ assert_equal(i, date_out.get.day)
114
+ end
115
+ end
116
+
117
+ def test_set_hour
118
+ @stmt.prepare("BEGIN :hour := TO_NUMBER(TO_CHAR(:date, 'HH24'), '99'); END;")
119
+ date_in = @stmt.bindByName(":date", OraDate)
120
+ hour_out = @stmt.bindByName(":hour", Fixnum)
121
+ date = OraDate.new()
122
+ HOUR_CHECK_TARGET.each do |i|
123
+ # set hour
124
+ date.hour = i
125
+ # check result via oracle.
126
+ date_in.set(date)
127
+ @stmt.execute(@svc)
128
+ assert_equal(i, hour_out.get())
129
+ end
130
+ end
131
+
132
+ def test_get_hour
133
+ @stmt.prepare("BEGIN :date := TO_DATE(TO_CHAR(:hour, '99'), 'HH24'); END;")
134
+ hour_in = @stmt.bindByName(":hour", Fixnum)
135
+ date_out = @stmt.bindByName(":date", OraDate)
136
+ HOUR_CHECK_TARGET.each do |i|
137
+ # set date via oracle.
138
+ hour_in.set(i)
139
+ @stmt.execute(@svc)
140
+ # check OraDate#hour
141
+ assert_equal(i, date_out.get.hour)
142
+ end
143
+ end
144
+
145
+ def test_set_minute
146
+ @stmt.prepare("BEGIN :minute := TO_NUMBER(TO_CHAR(:date, 'MI'), '99'); END;")
147
+ date_in = @stmt.bindByName(":date", OraDate)
148
+ minute_out = @stmt.bindByName(":minute", Fixnum)
149
+ date = OraDate.new()
150
+ MINUTE_CHECK_TARGET.each do |i|
151
+ # set minute
152
+ date.minute = i
153
+ # check result via oracle.
154
+ date_in.set(date)
155
+ @stmt.execute(@svc)
156
+ assert_equal(i, minute_out.get())
157
+ end
158
+ end
159
+
160
+ def test_get_minute
161
+ @stmt.prepare("BEGIN :date := TO_DATE(TO_CHAR(:minute, '99'), 'MI'); END;")
162
+ minute_in = @stmt.bindByName(":minute", Fixnum)
163
+ date_out = @stmt.bindByName(":date", OraDate)
164
+ MINUTE_CHECK_TARGET.each do |i|
165
+ # set date via oracle.
166
+ minute_in.set(i)
167
+ @stmt.execute(@svc)
168
+ # check OraDate#minute
169
+ assert_equal(i, date_out.get.minute)
170
+ end
171
+ end
172
+
173
+ def test_set_second
174
+ @stmt.prepare("BEGIN :second := TO_NUMBER(TO_CHAR(:date, 'SS'), '99'); END;")
175
+ date_in = @stmt.bindByName(":date", OraDate)
176
+ second_out = @stmt.bindByName(":second", Fixnum)
177
+ date = OraDate.new()
178
+ SECOND_CHECK_TARGET.each do |i|
179
+ # set second
180
+ date.second = i
181
+ # check result via oracle.
182
+ date_in.set(date)
183
+ @stmt.execute(@svc)
184
+ assert_equal(i, second_out.get())
185
+ end
186
+ end
187
+
188
+ def test_get_second
189
+ @stmt.prepare("BEGIN :date := TO_DATE(TO_CHAR(:second, '99'), 'SS'); END;")
190
+ second_in = @stmt.bindByName(":second", Fixnum)
191
+ date_out = @stmt.bindByName(":date", OraDate)
192
+ SECOND_CHECK_TARGET.each do |i|
193
+ # set date via oracle.
194
+ second_in.set(i)
195
+ @stmt.execute(@svc)
196
+ # check OraDate#second
197
+ assert_equal(i, date_out.get.second)
198
+ end
199
+ end
200
+
201
+ def test_compare
202
+ d1 = OraDate.new(2003,03,15,18,55,35)
203
+ d2 = OraDate.new(2003,03,15,18,55,35)
204
+ assert_equal(d1, d2)
205
+ assert_operator(d1, :<, OraDate.new(2004,03,15,18,55,35))
206
+ assert_operator(d1, :<, OraDate.new(2003,04,15,18,55,35))
207
+ assert_operator(d1, :<, OraDate.new(2003,03,16,18,55,35))
208
+ assert_operator(d1, :<, OraDate.new(2003,03,15,19,55,35))
209
+ assert_operator(d1, :<, OraDate.new(2003,03,15,18,56,35))
210
+ assert_operator(d1, :<, OraDate.new(2003,03,15,18,55,36))
211
+
212
+ assert_operator(OraDate.new(2002,03,15,18,55,35), :<, d1)
213
+ assert_operator(OraDate.new(2003,02,15,18,55,35), :<, d1)
214
+ assert_operator(OraDate.new(2003,03,14,18,55,35), :<, d1)
215
+ assert_operator(OraDate.new(2003,03,15,17,55,35), :<, d1)
216
+ assert_operator(OraDate.new(2003,03,15,18,54,35), :<, d1)
217
+ assert_operator(OraDate.new(2003,03,15,18,55,34), :<, d1)
218
+ end
219
+
220
+ def test_to_time
221
+ year, month, day, hour, minute, second = [2003,03,15,18,55,35]
222
+ dt = OraDate.new(year, month, day, hour, minute, second)
223
+ tm = Time.local(year, month, day, hour, minute, second)
224
+ assert_equal(tm, dt.to_time)
225
+
226
+ # year, month, day, hour, minute, second = [1900,1,1,0,0,0]
227
+ # dt = OraDate.new(year, month, day, hour, minute, second)
228
+ # assert_exception(RangeError) { dt.to_time }
229
+ end
230
+
231
+ def test_to_date
232
+ [[2003,03,15], [1900,1,1], [-4712, 1, 1]].each do |year, month, day|
233
+ odt = OraDate.new(year, month, day)
234
+ rdt = Date.new(year, month, day)
235
+ assert_equal(rdt, odt.to_date)
236
+ end
237
+ end
238
+
239
+ def test_dup
240
+ [[2003,03,15], [1900,1,1], [-4712, 1, 1]].each do |year, month, day|
241
+ dt = OraDate.new(year, month, day)
242
+ assert_equal(dt, dt.dup)
243
+ assert_equal(dt, dt.clone)
244
+ end
245
+ end
246
+
247
+ def test_marshal
248
+ [[2003,03,15], [1900,1,1], [-4712, 1, 1]].each do |year, month, day|
249
+ dt = OraDate.new(year, month, day)
250
+ assert_equal(dt, Marshal.load(Marshal.dump(dt)))
251
+ end
252
+ end
253
+
254
+ def teardown
255
+ @stmt.free()
256
+ @svc.logoff()
257
+ @env.free()
258
+ end
259
+ end
260
+
261
+ if $0 == __FILE__
262
+ RUNIT::CUI::TestRunner.run(TestOraDate.suite())
263
+ end
@@ -0,0 +1,149 @@
1
+ # Low-level API
2
+ require 'oci8'
3
+ require 'runit/testcase'
4
+ require 'runit/cui/testrunner'
5
+ require File.dirname(__FILE__) + '/config'
6
+
7
+ class TestOraNumber < RUNIT::TestCase
8
+
9
+ NUMBER_CHECK_TARGET = [
10
+ "12345678901234567890123456789012345678",
11
+ "1234567890123456789012345678901234567",
12
+ "1234567890123456789012345678901234567.8",
13
+ "12.345678901234567890123456789012345678",
14
+ "1.2345678901234567890123456789012345678",
15
+ "1.234567890123456789012345678901234567",
16
+ "0.0000000000000000000000000000000000001",
17
+ "0.000000000000000000000000000000000001",
18
+ "0",
19
+ "2147483647", # max of 32 bit signed value
20
+ "2147483648", # max of 32 bit signed value + 1
21
+ "-2147483648", # min of 32 bit signed value
22
+ "-2147483649", # min of 32 bit signed value - 1
23
+ "9223372036854775807", # max of 64 bit signed value
24
+ "9223372036854775808", # max of 64 bit signed value + 1
25
+ "-9223372036854775808", # min of 64 bit signed value
26
+ "-9223372036854775809", # min of 64 bit signed value - 1
27
+ "-12345678901234567890123456789012345678",
28
+ "-1234567890123456789012345678901234567",
29
+ "-123456789012345678901234567890123456",
30
+ "-1234567890123456789012345678901234567.8",
31
+ "-12.345678901234567890123456789012345678",
32
+ "-1.2345678901234567890123456789012345678",
33
+ "-0.0000000000000000000000000000000000001",
34
+ "-0.000000000000000000000000000000000001",
35
+ "-0.00000000000000000000000000000000001",
36
+ "1",
37
+ "20",
38
+ "300",
39
+ "-1",
40
+ "-20",
41
+ "-300",
42
+ "1.123",
43
+ "12.123",
44
+ "123.123",
45
+ "1.1",
46
+ "1.12",
47
+ "1.123",
48
+ "-1.123",
49
+ "-12.123",
50
+ "-123.123",
51
+ "-1.1",
52
+ "-1.12",
53
+ "-1.123",
54
+ ]
55
+
56
+ def setup
57
+ @env, @svc, @stmt = setup_lowapi()
58
+ end
59
+
60
+ def test_to_s
61
+ @stmt.prepare("BEGIN :number := TO_NUMBER(:str); END;")
62
+ number = @stmt.bindByName(":number", OraNumber)
63
+ str = @stmt.bindByName(":str", String, 40)
64
+ NUMBER_CHECK_TARGET.each do |val|
65
+ str.set(val)
66
+ @stmt.execute(@svc)
67
+ assert_equal(val, number.get.to_s)
68
+ end
69
+ end
70
+
71
+ def test_to_i
72
+ @stmt.prepare("BEGIN :number := TO_NUMBER(:str); END;")
73
+ number = @stmt.bindByName(":number", OraNumber)
74
+ str = @stmt.bindByName(":str", String, 40)
75
+ NUMBER_CHECK_TARGET.each do |val|
76
+ str.set(val)
77
+ @stmt.execute(@svc)
78
+ assert_equal(val.to_i, number.get.to_i)
79
+ end
80
+ end
81
+
82
+ def test_to_f
83
+ @stmt.prepare("BEGIN :number := TO_NUMBER(:str); END;")
84
+ number = @stmt.bindByName(":number", OraNumber)
85
+ str = @stmt.bindByName(":str", String, 40)
86
+ NUMBER_CHECK_TARGET.each do |val|
87
+ str.set(val)
88
+ @stmt.execute(@svc)
89
+ assert_equal(val.to_f, number.get.to_f)
90
+ end
91
+ end
92
+
93
+ def test_uminus
94
+ @stmt.prepare("BEGIN :number := - TO_NUMBER(:str); END;")
95
+ number = @stmt.bindByName(":number", OraNumber)
96
+ str = @stmt.bindByName(":str", String, 40)
97
+ NUMBER_CHECK_TARGET.each do |val|
98
+ str.set(val)
99
+ @stmt.execute(@svc)
100
+ assert_equal(val, (- (number.get)).to_s)
101
+ end
102
+ end
103
+
104
+ def test_dup
105
+ @stmt.prepare("BEGIN :number := TO_NUMBER(:str); END;")
106
+ number = @stmt.bindByName(":number", OraNumber)
107
+ str = @stmt.bindByName(":str", String, 40)
108
+ NUMBER_CHECK_TARGET.each do |val|
109
+ str.set(val)
110
+ @stmt.execute(@svc)
111
+ n = number.get
112
+ assert_equal(n.to_s, n.dup.to_s)
113
+ assert_equal(n.to_s, n.clone.to_s)
114
+ end
115
+ end
116
+
117
+ def test_marshal
118
+ @stmt.prepare("BEGIN :number := TO_NUMBER(:str); END;")
119
+ number = @stmt.bindByName(":number", OraNumber)
120
+ str = @stmt.bindByName(":str", String, 40)
121
+ NUMBER_CHECK_TARGET.each do |val|
122
+ str.set(val)
123
+ @stmt.execute(@svc)
124
+ n = number.get
125
+ assert_equal(n.to_s, Marshal.load(Marshal.dump(n)).to_s)
126
+ end
127
+ end
128
+
129
+ def test_new_from_string
130
+ @stmt.prepare("BEGIN :number := TO_NUMBER(:str); END;")
131
+ number = @stmt.bindByName(":number", OraNumber)
132
+ str = @stmt.bindByName(":str", String, 40)
133
+ (NUMBER_CHECK_TARGET + ["1.230", "1.2300", "1.23000"]).each do |val|
134
+ str.set(val)
135
+ @stmt.execute(@svc)
136
+ assert_equal(number.get.to_s, OraNumber.new(val).to_s)
137
+ end
138
+ end
139
+
140
+ def teardown
141
+ @stmt.free()
142
+ @svc.logoff()
143
+ @env.free()
144
+ end
145
+ end
146
+
147
+ if $0 == __FILE__
148
+ RUNIT::CUI::TestRunner.run(TestOraNumber.suite())
149
+ end
@@ -0,0 +1,38 @@
1
+ require 'oci8'
2
+ require 'runit/testcase'
3
+ require 'runit/cui/testrunner'
4
+ require File.dirname(__FILE__) + '/config'
5
+
6
+ class TestRowid < RUNIT::TestCase
7
+
8
+ def setup
9
+ @conn = get_oci_connection()
10
+ end
11
+
12
+ def teardown
13
+ @conn.logoff
14
+ end
15
+
16
+ def test_rowid
17
+ drop_table('test_table')
18
+ sql = <<-EOS
19
+ CREATE TABLE test_table (N NUMBER(38))
20
+ EOS
21
+ @conn.exec(sql)
22
+ cursor = @conn.parse("INSERT INTO test_table values(1)");
23
+ cursor.exec
24
+ rid1 = cursor.rowid
25
+ assert_instance_of(String, rid1)
26
+ cursor.close
27
+ rid2 = nil
28
+ @conn.exec('select rowid from test_table where rowid = :1', rid1) do |row|
29
+ rid2 = row[0]
30
+ end
31
+ assert_equal(rid2, rid1)
32
+ drop_table('test_table')
33
+ end
34
+ end # TestRowid
35
+
36
+ if $0 == __FILE__
37
+ RUNIT::CUI::TestRunner.run(TestRowid.suite())
38
+ end