ruby-oci8 2.1.8-x86-mingw32 → 2.2.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -105,7 +105,7 @@ class TestConnectionPool < Minitest::Test
105
105
  assert_equal(non_blocking ? max_cnt : min_cnt, pool.open_count, msg) # open_count doesn't shrink.
106
106
  assert_equal(0, pool.busy_count, msg)
107
107
  conns[0].ping # make a network roundtrip.
108
- sleep(1)
108
+ sleep(0.5)
109
109
  # open_count shrinks.
110
110
  # The decrement count depends on Oracle version.
111
111
  assert_operator(pool.open_count, :<, max_cnt, msg)
@@ -481,8 +481,20 @@ EOS
481
481
  def test_client_driver_name
482
482
  if OCI8.oracle_client_version >= OCI8::ORAVER_11_1 and @conn.oracle_server_version >= OCI8::ORAVER_11_1
483
483
  sid = @conn.select_one("select userenv('sid') from dual")[0].to_i
484
- driver_name = @conn.select_one('select client_driver from v$session_connect_info where sid = :1', sid)[0]
485
- assert_equal('rubyoci8', driver_name)
484
+ cursor = @conn.parse('select client_driver from v$session_connect_info where sid = :1')
485
+ cursor.exec(sid)
486
+ column_size = cursor.column_metadata[0].data_size
487
+ expected_value = case column_size
488
+ when 30 # Oracle version >= 12.1.0.2
489
+ "ruby-oci8 : #{OCI8::VERSION}"
490
+ when 9 # Oracle version < 12.1.0.2
491
+ 'ruby-oci' # only the first 8 characters
492
+ else
493
+ raise "Unknown column size #{column_size}"
494
+ end
495
+ driver_name = cursor.fetch[0]
496
+ cursor.close
497
+ assert_equal(expected_value, driver_name)
486
498
  end
487
499
  end
488
500
  end # TestOCI8
@@ -0,0 +1,967 @@
1
+ require 'oci8'
2
+ require File.dirname(__FILE__) + '/config'
3
+
4
+ if $oracle_version < OCI8::ORAVER_12_1
5
+ raise "Package types are not supported in this Oracle version."
6
+ end
7
+
8
+ conn = OCI8.new($dbuser, $dbpass, $dbname)
9
+ test_package_version = nil
10
+ begin
11
+ cursor = conn.parse('begin :1 := rb_test_pkg.package_version; end;')
12
+ cursor.bind_param(1, nil, Integer)
13
+ cursor.exec
14
+ test_package_version = cursor[1]
15
+ cursor.close
16
+ rescue OCIError
17
+ raise if $!.code != 6550
18
+ end
19
+ raise <<EOS if test_package_version != 1
20
+ You need to execute SQL statements in #{File.dirname(__FILE__)}/setup_test_package.sql as follows:
21
+
22
+ $ sqlplus USERNAME/PASSWORD
23
+ SQL> @test/setup_test_package.sql
24
+
25
+ EOS
26
+
27
+ class TestPackageType < Minitest::Test
28
+ def setup
29
+ @conn = get_oci8_connection
30
+ end
31
+
32
+ def teardown
33
+ @conn.logoff
34
+ end
35
+
36
+ def check_attributes(msg, obj, attrs)
37
+ attrs.each do |method, expected_value|
38
+ val = method.is_a?(Array) ? obj[method[0]] : obj.send(method)
39
+ if expected_value.is_a? Hash
40
+ check_attributes("#{msg} > #{method}", val, expected_value)
41
+ else
42
+ assert_equal(expected_value, val, "#{msg} > #{method}")
43
+ end
44
+ end
45
+ end
46
+
47
+ def test_describe_package
48
+ integer_type_attrs = {
49
+ :class => OCI8::Metadata::Type,
50
+ #:typecode => nil,
51
+ #:collection_typecode => nil,
52
+ :is_incomplete_type? => false,
53
+ :is_system_type? => true,
54
+ :is_predefined_type? => true,
55
+ :is_transient_type? => false,
56
+ :is_system_generated_type? => false,
57
+ :has_nested_table? => false,
58
+ :has_lob? => false,
59
+ :has_file? => false,
60
+ #:collection_element => nil,
61
+ :num_type_attrs => 0,
62
+ :num_type_methods => 0,
63
+ #:map_method => nil,
64
+ #:order_method => nil,
65
+ :is_invoker_rights? => false,
66
+ :name => 'INTEGER',
67
+ :schema_name => 'SYS',
68
+ :is_final_type? => true,
69
+ :is_instantiable_type? => true,
70
+ :is_subtype? => false,
71
+ :supertype_schema_name => nil,
72
+ :supertype_name => nil,
73
+ :package_name => nil,
74
+ :type_attrs => [],
75
+ #:type_methods => [],
76
+ :inspect => '#<OCI8::Metadata::Type:(0) SYS.INTEGER>', # TODO: change to "INTEGER"
77
+ }
78
+
79
+ pls_integer_type_attrs = {
80
+ :class => OCI8::Metadata::Type,
81
+ #:typecode => nil,
82
+ #:collection_typecode => nil,
83
+ :is_incomplete_type? => false,
84
+ :is_system_type? => true,
85
+ :is_predefined_type? => true,
86
+ :is_transient_type? => false,
87
+ :is_system_generated_type? => false,
88
+ :has_nested_table? => false,
89
+ :has_lob? => false,
90
+ :has_file? => false,
91
+ #:collection_element => nil,
92
+ :num_type_attrs => 0,
93
+ :num_type_methods => 0,
94
+ #:map_method => nil,
95
+ #:order_method => nil,
96
+ :is_invoker_rights? => false,
97
+ :name => 'PL/SQL PLS INTEGER',
98
+ :schema_name => 'SYS',
99
+ :is_final_type? => true,
100
+ :is_instantiable_type? => true,
101
+ :is_subtype? => false,
102
+ :supertype_schema_name => nil,
103
+ :supertype_name => nil,
104
+ :package_name => nil,
105
+ :type_attrs => [],
106
+ #:type_methods => [],
107
+ :inspect => '#<OCI8::Metadata::Type:(0) SYS.PL/SQL PLS INTEGER>', # TODO: change to "PLS_INTEGER"
108
+ }
109
+
110
+ boolean_type_attrs = {
111
+ :class => OCI8::Metadata::Type,
112
+ #:typecode => nil,
113
+ #:collection_typecode => nil,
114
+ :is_incomplete_type? => false,
115
+ :is_system_type? => true,
116
+ :is_predefined_type? => true,
117
+ :is_transient_type? => false,
118
+ :is_system_generated_type? => false,
119
+ :has_nested_table? => false,
120
+ :has_lob? => false,
121
+ :has_file? => false,
122
+ #:collection_element => nil,
123
+ :num_type_attrs => 0,
124
+ :num_type_methods => 0,
125
+ #:map_method => nil,
126
+ #:order_method => nil,
127
+ :is_invoker_rights? => false,
128
+ :name => 'PL/SQL BOOLEAN',
129
+ :schema_name => 'SYS',
130
+ :is_final_type? => true,
131
+ :is_instantiable_type? => true,
132
+ :is_subtype? => false,
133
+ :supertype_schema_name => nil,
134
+ :supertype_name => nil,
135
+ :package_name => nil,
136
+ :type_attrs => [],
137
+ #:type_methods => [],
138
+ :inspect => '#<OCI8::Metadata::Type:(0) SYS.PL/SQL BOOLEAN>', # TODO: change to "BOOLEAN"
139
+ }
140
+
141
+ varchar2_type_attrs = {
142
+ :class => OCI8::Metadata::Type,
143
+ #:typecode => nil,
144
+ #:collection_typecode => nil,
145
+ :is_incomplete_type? => false,
146
+ :is_system_type? => true,
147
+ :is_predefined_type? => true,
148
+ :is_transient_type? => false,
149
+ :is_system_generated_type? => false,
150
+ :has_nested_table? => false,
151
+ :has_lob? => false,
152
+ :has_file? => false,
153
+ #:collection_element => nil,
154
+ :num_type_attrs => 0,
155
+ :num_type_methods => 0,
156
+ #:map_method => nil,
157
+ #:order_method => nil,
158
+ :is_invoker_rights? => false,
159
+ :name => 'VARCHAR2',
160
+ :schema_name => 'SYS',
161
+ :is_final_type? => true,
162
+ :is_instantiable_type? => true,
163
+ :is_subtype? => false,
164
+ :supertype_schema_name => nil,
165
+ :supertype_name => nil,
166
+ :package_name => nil,
167
+ :type_attrs => [],
168
+ #:type_methods => #[],
169
+ :inspect => '#<OCI8::Metadata::Type:(0) SYS.VARCHAR2>', # TODO: change to "VARCHAR2"
170
+ }
171
+
172
+ array_of_integer_type_attrs = {
173
+ :class => OCI8::Metadata::Type,
174
+ :typecode => :named_collection,
175
+ :collection_typecode => :varray,
176
+ :is_incomplete_type? => false,
177
+ :is_system_type? => false,
178
+ :is_predefined_type? => false,
179
+ :is_transient_type? => false,
180
+ :is_system_generated_type? => false,
181
+ :has_nested_table? => false,
182
+ :has_lob? => false,
183
+ :has_file? => false,
184
+ :collection_element => {
185
+ :class => OCI8::Metadata::Collection,
186
+ :data_size => 22,
187
+ :typecode => :integer,
188
+ :data_type => :number,
189
+ :num_elems => 50,
190
+ :precision => 38,
191
+ :scale => 0,
192
+ :type_name => 'INTEGER',
193
+ :schema_name => 'SYS',
194
+ :type_metadata => integer_type_attrs,
195
+ :inspect => '#<OCI8::Metadata::Collection: NUMBER(38)>', # TODO: change to "INTEGER"
196
+ },
197
+ :num_type_attrs => 0,
198
+ :num_type_methods => 0,
199
+ :map_method => nil,
200
+ :order_method => nil,
201
+ :is_invoker_rights? => false,
202
+ :name => 'ARRAY_OF_INTEGER',
203
+ :schema_name => @conn.username,
204
+ :is_final_type? => true,
205
+ :is_instantiable_type? => true,
206
+ :is_subtype? => false,
207
+ :supertype_schema_name => nil,
208
+ :supertype_name => nil,
209
+ :package_name => 'RB_TEST_PKG',
210
+ :type_attrs => [],
211
+ :type_methods => [],
212
+ :inspect => "#<OCI8::Metadata::Type:(0) #{@conn.username}.ARRAY_OF_INTEGER>", # TODO: change to "#{@conn.username}.RB_TEST_PKG.ARRAY_OF_INTEGER"
213
+ }
214
+
215
+ table_of_pls_integer_type_attrs = {
216
+ :class => OCI8::Metadata::Type,
217
+ :typecode => :named_collection,
218
+ :collection_typecode => :table,
219
+ :is_incomplete_type? => false,
220
+ :is_system_type? => false,
221
+ :is_predefined_type? => false,
222
+ :is_transient_type? => false,
223
+ :is_system_generated_type? => false,
224
+ :has_nested_table? => true,
225
+ :has_lob? => false,
226
+ :has_file? => false,
227
+ :collection_element => {
228
+ :class => OCI8::Metadata::Collection,
229
+ :data_size => 0,
230
+ :typecode => :pls_integer,
231
+ :data_type => :pls_integer,
232
+ :num_elems => 0,
233
+ :precision => 0,
234
+ :scale => 0,
235
+ :type_name => 'PL/SQL PLS INTEGER',
236
+ :schema_name => 'SYS',
237
+ :type_metadata => pls_integer_type_attrs,
238
+ :inspect => '#<OCI8::Metadata::Collection: PLS_INTEGER>',
239
+ },
240
+ :num_type_attrs => 0,
241
+ :num_type_methods => 0,
242
+ :map_method => nil,
243
+ :order_method => nil,
244
+ :is_invoker_rights? => false,
245
+ :name => 'TABLE_OF_PLS_INTEGER',
246
+ :schema_name => @conn.username,
247
+ :is_final_type? => true,
248
+ :is_instantiable_type? => true,
249
+ :is_subtype? => false,
250
+ :supertype_schema_name => nil,
251
+ :supertype_name => nil,
252
+ :package_name => 'RB_TEST_PKG',
253
+ :type_attrs => [],
254
+ :type_methods => [],
255
+ :inspect => "#<OCI8::Metadata::Type:(0) #{@conn.username}.TABLE_OF_PLS_INTEGER>", # TODO: change to "#{@conn.username}.RB_TEST_PKG.TABLE_OF_PLS_INTEGER"
256
+ }
257
+
258
+ table_of_boolean_type_attrs = {
259
+ :class => OCI8::Metadata::Type,
260
+ :typecode => :named_collection,
261
+ :collection_typecode => :table,
262
+ :is_incomplete_type? => false,
263
+ :is_system_type? => false,
264
+ :is_predefined_type? => false,
265
+ :is_transient_type? => false,
266
+ :is_system_generated_type? => false,
267
+ :has_nested_table? => true,
268
+ :has_lob? => false,
269
+ :has_file? => false,
270
+ :collection_element => {
271
+ :class => OCI8::Metadata::Collection,
272
+ :data_size => 0,
273
+ :typecode => :boolean,
274
+ :data_type => :boolean,
275
+ :num_elems => 0,
276
+ :precision => 0,
277
+ :scale => 0,
278
+ :type_name => 'PL/SQL BOOLEAN',
279
+ :schema_name => 'SYS',
280
+ :type_metadata => boolean_type_attrs,
281
+ :inspect => '#<OCI8::Metadata::Collection: BOOLEAN>',
282
+ },
283
+ :num_type_attrs => 0,
284
+ :num_type_methods => 0,
285
+ :map_method => nil,
286
+ :order_method => nil,
287
+ :is_invoker_rights? => false,
288
+ :name => 'TABLE_OF_BOOLEAN',
289
+ :schema_name => @conn.username,
290
+ :is_final_type? => true,
291
+ :is_instantiable_type? => true,
292
+ :is_subtype? => false,
293
+ :supertype_schema_name => nil,
294
+ :supertype_name => nil,
295
+ :package_name => 'RB_TEST_PKG',
296
+ :type_attrs => [],
297
+ :type_methods => [],
298
+ :inspect => "#<OCI8::Metadata::Type:(0) #{@conn.username}.TABLE_OF_BOOLEAN>", # TODO: change to "#{@conn.username}.RB_TEST_PKG.TABLE_OF_BOOLEAN"
299
+ }
300
+
301
+ indexed_table_of_varchar2_type_attrs = {
302
+ :class => OCI8::Metadata::Type,
303
+ :typecode => :named_collection,
304
+ :collection_typecode => :itable,
305
+ :is_incomplete_type? => false,
306
+ :is_system_type? => false,
307
+ :is_predefined_type? => false,
308
+ :is_transient_type? => false,
309
+ :is_system_generated_type? => false,
310
+ :has_nested_table? => false,
311
+ :has_lob? => false,
312
+ :has_file? => false,
313
+ :collection_element => {
314
+ :class => OCI8::Metadata::Collection,
315
+ :data_size => 10,
316
+ :typecode => :varchar2,
317
+ :data_type => :varchar2,
318
+ :num_elems => 5,
319
+ :precision => 0,
320
+ :scale => 0,
321
+ :type_name => 'VARCHAR2',
322
+ :schema_name => 'SYS',
323
+ :type_metadata => varchar2_type_attrs,
324
+ :inspect => '#<OCI8::Metadata::Collection: VARCHAR2(10)>',
325
+ },
326
+ :num_type_attrs => 0,
327
+ :num_type_methods => 0,
328
+ :map_method => nil,
329
+ :order_method => nil,
330
+ :is_invoker_rights? => false,
331
+ :name => 'INDEXED_TABLE_OF_VARCHAR2',
332
+ :schema_name => @conn.username,
333
+ :is_final_type? => true,
334
+ :is_instantiable_type? => true,
335
+ :is_subtype? => false,
336
+ :supertype_schema_name => nil,
337
+ :supertype_name => nil,
338
+ :package_name => 'RB_TEST_PKG',
339
+ :type_attrs => [],
340
+ :type_methods => [],
341
+ :inspect => "#<OCI8::Metadata::Type:(0) #{@conn.username}.INDEXED_TABLE_OF_VARCHAR2>", # TODO: change to "#{@conn.username}.RB_TEST_PKG.INDEXED_TABLE_OF_VARCHAR2"
342
+ }
343
+
344
+ rec1_type_attrs = {
345
+ :class => OCI8::Metadata::Type,
346
+ :typecode => :record,
347
+ :collection_typecode => nil,
348
+ :is_incomplete_type? => false,
349
+ :is_system_type? => false,
350
+ :is_predefined_type? => false,
351
+ :is_transient_type? => false,
352
+ :is_system_generated_type? => false,
353
+ :has_nested_table? => false,
354
+ :has_lob? => false,
355
+ :has_file? => false,
356
+ :collection_element => nil,
357
+ :num_type_attrs => 2,
358
+ :num_type_methods => 0,
359
+ :map_method => nil,
360
+ :order_method => nil,
361
+ :is_invoker_rights? => false,
362
+ :name => 'REC1',
363
+ :schema_name => @conn.username,
364
+ :is_final_type? => true,
365
+ :is_instantiable_type? => true,
366
+ :is_subtype? => false,
367
+ :supertype_schema_name => nil,
368
+ :supertype_name => nil,
369
+ :package_name => 'RB_TEST_PKG',
370
+ :type_attrs => {
371
+ :class => Array,
372
+ :size => 2,
373
+ [0] => {
374
+ :class => OCI8::Metadata::TypeAttr,
375
+ :data_size => 0,
376
+ :typecode => :pls_integer,
377
+ :data_type => :pls_integer,
378
+ :name => 'I',
379
+ :precision => 0,
380
+ :scale => 0,
381
+ :type_name => 'PL/SQL PLS INTEGER',
382
+ :schema_name => 'SYS',
383
+ :fsprecision => 0,
384
+ :lfprecision => 0,
385
+ :type_metadata => pls_integer_type_attrs,
386
+ :inspect => '#<OCI8::Metadata::TypeAttr: I PLS_INTEGER>',
387
+ },
388
+ [1] => {
389
+ :class => OCI8::Metadata::TypeAttr,
390
+ :data_size => 22,
391
+ :typecode => :integer,
392
+ :data_type => :number,
393
+ :name => 'J',
394
+ :precision => 38,
395
+ :scale => 0,
396
+ :type_name => 'INTEGER',
397
+ :schema_name => 'SYS',
398
+ :fsprecision => 0,
399
+ :lfprecision => 0,
400
+ :type_metadata => integer_type_attrs,
401
+ :inspect => '#<OCI8::Metadata::TypeAttr: J NUMBER(38)>', # TODO: change to "INTEGER"
402
+ },
403
+ },
404
+ :type_methods => [],
405
+ :inspect => "#<OCI8::Metadata::Type:(0) #{@conn.username}.REC1>", # TODO: change to "#{@conn.username}.RB_TEST_PKG.REC1"
406
+ }
407
+
408
+ rec2_type_attrs = {
409
+ :class => OCI8::Metadata::Type,
410
+ :typecode => :record,
411
+ :collection_typecode => nil,
412
+ :is_incomplete_type? => false,
413
+ :is_system_type? => false,
414
+ :is_predefined_type? => false,
415
+ :is_transient_type? => false,
416
+ :is_system_generated_type? => false,
417
+ :has_nested_table? => false,
418
+ :has_lob? => false,
419
+ :has_file? => false,
420
+ :collection_element => nil,
421
+ :num_type_attrs => 3,
422
+ :num_type_methods => 0,
423
+ :map_method => nil,
424
+ :order_method => nil,
425
+ :is_invoker_rights? => false,
426
+ :name => 'REC2',
427
+ :schema_name => @conn.username,
428
+ :is_final_type? => true,
429
+ :is_instantiable_type? => true,
430
+ :is_subtype? => false,
431
+ :supertype_schema_name => nil,
432
+ :supertype_name => nil,
433
+ :package_name => 'RB_TEST_PKG',
434
+ :type_attrs => {
435
+ :class => Array,
436
+ :size => 3,
437
+ [0] => {
438
+ :class => OCI8::Metadata::TypeAttr,
439
+ :data_size => 0,
440
+ :typecode => :boolean,
441
+ :data_type => :boolean,
442
+ :name => 'B',
443
+ :precision => 0,
444
+ :scale => 0,
445
+ :type_name => 'PL/SQL BOOLEAN',
446
+ :schema_name => 'SYS',
447
+ :fsprecision => 0,
448
+ :lfprecision => 0,
449
+ :type_metadata => boolean_type_attrs,
450
+ :inspect => '#<OCI8::Metadata::TypeAttr: B BOOLEAN>',
451
+ },
452
+ [1] => {
453
+ :class => OCI8::Metadata::TypeAttr,
454
+ :data_size => 0,
455
+ :typecode => :named_collection,
456
+ :data_type => :named_type,
457
+ :name => 'IT',
458
+ :precision => 0,
459
+ :scale => 0,
460
+ :type_name => 'INDEXED_TABLE_OF_VARCHAR2',
461
+ :schema_name => @conn.username,
462
+ :fsprecision => 0,
463
+ :lfprecision => 0,
464
+ :type_metadata => indexed_table_of_varchar2_type_attrs,
465
+ :inspect => "#<OCI8::Metadata::TypeAttr: IT #{@conn.username}.INDEXED_TABLE_OF_VARCHAR2>", # TODO: change to "#{@conn.username}.RB_TEST_PKG.INDEXED_TABLE_OF_VARCHAR2"
466
+ },
467
+ [2] => {
468
+ :class => OCI8::Metadata::TypeAttr,
469
+ :data_size => 0,
470
+ :typecode => :record,
471
+ :data_type => :record,
472
+ :name => 'REC',
473
+ :precision => 0,
474
+ :scale => 0,
475
+ :type_name => 'REC1',
476
+ :schema_name => @conn.username,
477
+ :fsprecision => 0,
478
+ :lfprecision => 0,
479
+ :type_metadata => rec1_type_attrs,
480
+ :inspect => "#<OCI8::Metadata::TypeAttr: REC #{@conn.username}.REC1>", # TODO: change to "#{@conn.username}.RB_TEST_PKG.REC1"
481
+ },
482
+ },
483
+ :type_methods => [],
484
+ :inspect => "#<OCI8::Metadata::Type:(0) #{@conn.username}.REC2>", # TODO: change to "#{@conn.username}.RB_TEST_PKG.REC2"
485
+ }
486
+
487
+ table_of_rec1_type_attrs = {
488
+ :class => OCI8::Metadata::Type,
489
+ :typecode => :named_collection,
490
+ :collection_typecode => :table,
491
+ :is_incomplete_type? => false,
492
+ :is_system_type? => false,
493
+ :is_predefined_type? => false,
494
+ :is_transient_type? => false,
495
+ :is_system_generated_type? => false,
496
+ :has_nested_table? => true,
497
+ :has_lob? => false,
498
+ :has_file? => false,
499
+ :collection_element => {
500
+ :class => OCI8::Metadata::Collection,
501
+ :data_size => 0,
502
+ :typecode => :record,
503
+ :data_type => :record,
504
+ :num_elems => 0,
505
+ :precision => 0,
506
+ :scale => 0,
507
+ :type_name => 'REC1',
508
+ :schema_name => @conn.username,
509
+ :type_metadata => rec1_type_attrs,
510
+ :inspect => "#<OCI8::Metadata::Collection: #{@conn.username}.REC1>", # TODO: change to "#{@conn.username}.RB_TEST_PKG.REC1"
511
+ },
512
+ :num_type_attrs => 0,
513
+ :num_type_methods => 0,
514
+ :map_method => nil,
515
+ :order_method => nil,
516
+ :is_invoker_rights? => false,
517
+ :name => 'TABLE_OF_REC1',
518
+ :schema_name => @conn.username,
519
+ :is_final_type? => true,
520
+ :is_instantiable_type? => true,
521
+ :is_subtype? => false,
522
+ :supertype_schema_name => nil,
523
+ :supertype_name => nil,
524
+ :package_name => 'RB_TEST_PKG',
525
+ :type_attrs => [],
526
+ :type_methods => [],
527
+ :inspect => "#<OCI8::Metadata::Type:(0) #{@conn.username}.TABLE_OF_REC1>", # TODO: change to "#{@conn.username}.RB_TEST_PKG.TABLE_OF_REC1"
528
+ }
529
+
530
+ table_of_rec2_type_attrs = {
531
+ :class => OCI8::Metadata::Type,
532
+ :typecode => :named_collection,
533
+ :collection_typecode => :table,
534
+ :is_incomplete_type? => false,
535
+ :is_system_type? => false,
536
+ :is_predefined_type? => false,
537
+ :is_transient_type? => false,
538
+ :is_system_generated_type? => false,
539
+ :has_nested_table? => true,
540
+ :has_lob? => false,
541
+ :has_file? => false,
542
+ :collection_element => {
543
+ :class => OCI8::Metadata::Collection,
544
+ :data_size => 0,
545
+ :typecode => :record,
546
+ :data_type => :record,
547
+ :num_elems => 0,
548
+ :precision => 0,
549
+ :scale => 0,
550
+ :type_name => 'REC2',
551
+ :schema_name => @conn.username,
552
+ :type_metadata => rec2_type_attrs,
553
+ :inspect => "#<OCI8::Metadata::Collection: #{@conn.username}.REC2>",
554
+ #:inspect => "#<OCI8::Metadata::Collection: #{@conn.username}.RB_TEST_PKG.REC2>",
555
+ },
556
+ :num_type_attrs => 0,
557
+ :num_type_methods => 0,
558
+ :map_method => nil,
559
+ :order_method => nil,
560
+ :is_invoker_rights? => false,
561
+ :name => 'TABLE_OF_REC2',
562
+ :schema_name => @conn.username,
563
+ :is_final_type? => true,
564
+ :is_instantiable_type? => true,
565
+ :is_subtype? => false,
566
+ :supertype_schema_name => nil,
567
+ :supertype_name => nil,
568
+ :package_name => 'RB_TEST_PKG',
569
+ :type_attrs => [],
570
+ :type_methods => [],
571
+ :inspect => "#<OCI8::Metadata::Type:(0) #{@conn.username}.TABLE_OF_REC2>", # TODO: change to "#{@conn.username}.RB_TEST_PKG.TABLE_OF_REC2"
572
+ }
573
+
574
+ type_metadata_attrs = {
575
+ 'ARRAY_OF_INTEGER' => array_of_integer_type_attrs,
576
+ 'TABLE_OF_PLS_INTEGER' => table_of_pls_integer_type_attrs,
577
+ 'TABLE_OF_BOOLEAN' => table_of_boolean_type_attrs,
578
+ 'INDEXED_TABLE_OF_VARCHAR2' => indexed_table_of_varchar2_type_attrs,
579
+ 'REC1' => rec1_type_attrs,
580
+ 'REC2' => rec2_type_attrs,
581
+ 'TABLE_OF_REC1' => table_of_rec1_type_attrs,
582
+ 'TABLE_OF_REC2' => table_of_rec2_type_attrs,
583
+ }
584
+
585
+ sum_table_of_pls_integer_subprogram_attrs = {
586
+ :class => OCI8::Metadata::Function,
587
+ :obj_name => 'SUM_TABLE_OF_PLS_INTEGER',
588
+ :obj_schema => nil,
589
+ :is_invoker_rights? => false,
590
+ :name => 'SUM_TABLE_OF_PLS_INTEGER',
591
+ :overload_id => 0,
592
+ :arguments => {
593
+ :class => Array,
594
+ :size => 2,
595
+ [0] => {
596
+ :class => OCI8::Metadata::Argument,
597
+ :obj_name => nil,
598
+ :obj_schema => nil,
599
+ :name => "",
600
+ :position => 0,
601
+ #:typecode => nil,
602
+ :data_type => 3,
603
+ :data_size => 0,
604
+ :precision => 0,
605
+ :scale => 0,
606
+ :level => 0,
607
+ :has_default => 0,
608
+ :has_default? => false,
609
+ :iomode => :out,
610
+ :radix => 0,
611
+ :type_name => "",
612
+ :schema_name => "",
613
+ :sub_name => "",
614
+ :link => "",
615
+ #:type_metadata => nil,
616
+ :arguments => [],
617
+ :inspect => '#<OCI8::Metadata::Argument: unknown(3)>', # TODO: change to "PLS_INTEGER"
618
+ },
619
+ [1] => {
620
+ :class => OCI8::Metadata::Argument,
621
+ :obj_name => nil,
622
+ :obj_schema => nil,
623
+ :name => "TBL",
624
+ :position => 1,
625
+ #:typecode => nil,
626
+ :data_type => :named_type,
627
+ :data_size => 0,
628
+ :precision => 0,
629
+ :scale => 0,
630
+ :level => 0,
631
+ :has_default => 0,
632
+ :has_default? => false,
633
+ :iomode => :in,
634
+ :radix => 0,
635
+ :type_name => "RB_TEST_PKG",
636
+ :schema_name => @conn.username,
637
+ :sub_name => "TABLE_OF_PLS_INTEGER",
638
+ :link => "",
639
+ #:type_metadata => nil,
640
+ :arguments => {
641
+ :class => Array,
642
+ :size => 1,
643
+ [0] => {
644
+ :class => OCI8::Metadata::Argument,
645
+ :obj_name => nil,
646
+ :obj_schema => nil,
647
+ :name => "",
648
+ :position => 1,
649
+ #:typecode => nil,
650
+ :data_type => 3,
651
+ :data_size => 0,
652
+ :precision => 0,
653
+ :scale => 0,
654
+ :level => 1,
655
+ :has_default => 0,
656
+ :has_default? => false,
657
+ :iomode => :in,
658
+ :radix => 0,
659
+ :type_name => "",
660
+ :schema_name => "",
661
+ :sub_name => "",
662
+ :link => "",
663
+ #:type_metadata => nil,
664
+ :arguments => [],
665
+ :inspect => '#<OCI8::Metadata::Argument: unknown(3)>', # TODO: change to "PLS_INTEGER"
666
+ },
667
+ },
668
+ :inspect => "#<OCI8::Metadata::Argument: TBL #{@conn.username}.RB_TEST_PKG>", # TODO: change to "#{@conn.username}.RB_TEST_PKG.TABLE_OF_PLS_INTEGER"
669
+ },
670
+ },
671
+ :is_standalone? => false,
672
+ :inspect => '#<OCI8::Metadata::Function: SUM_TABLE_OF_PLS_INTEGER>', # FIXME
673
+ }
674
+
675
+ add_rec1_values_subprogram_attrs = {
676
+ :class => OCI8::Metadata::Function,
677
+ :obj_name => 'ADD_REC1_VALUES',
678
+ :obj_schema => nil,
679
+ :is_invoker_rights? => false,
680
+ :name => 'ADD_REC1_VALUES',
681
+ :overload_id => 0,
682
+ :arguments => {
683
+ :class => Array,
684
+ :size => 2,
685
+ [0] => {
686
+ :class => OCI8::Metadata::Argument,
687
+ :obj_name => nil,
688
+ :obj_schema => nil,
689
+ :name => "",
690
+ :position => 0,
691
+ #:typecode => nil,
692
+ :data_type => 3,
693
+ :data_size => 0,
694
+ :precision => 0,
695
+ :scale => 0,
696
+ :level => 0,
697
+ :has_default => 0,
698
+ :has_default? => false,
699
+ :iomode => :out,
700
+ :radix => 0,
701
+ :type_name => "",
702
+ :schema_name => "",
703
+ :sub_name => "",
704
+ :link => "",
705
+ #:type_metadata => nil,
706
+ :arguments => [],
707
+ :inspect => '#<OCI8::Metadata::Argument: unknown(3)>', # TODO: change to "PLS_INTEGER"
708
+ },
709
+ [1] => {
710
+ :class => OCI8::Metadata::Argument,
711
+ :obj_name => nil,
712
+ :obj_schema => nil,
713
+ :name => "TBL",
714
+ :position => 1,
715
+ #:typecode => nil,
716
+ :data_type => :named_type,
717
+ :data_size => 0,
718
+ :precision => 0,
719
+ :scale => 0,
720
+ :level => 0,
721
+ :has_default => 0,
722
+ :has_default? => false,
723
+ :iomode => :in,
724
+ :radix => 0,
725
+ :type_name => "RB_TEST_PKG",
726
+ :schema_name => @conn.username,
727
+ :sub_name => "TABLE_OF_REC1",
728
+ :link => "",
729
+ #:type_metadata => nil,
730
+ :arguments => {
731
+ :class => Array,
732
+ :size => 1,
733
+ [0] => {
734
+ :class => OCI8::Metadata::Argument,
735
+ :obj_name => nil,
736
+ :obj_schema => nil,
737
+ :name => "",
738
+ :position => 1,
739
+ #:typecode => nil,
740
+ :data_type => 250,
741
+ :data_size => 0,
742
+ :precision => 0,
743
+ :scale => 0,
744
+ :level => 1,
745
+ :has_default => 0,
746
+ :has_default? => false,
747
+ :iomode => :in,
748
+ :radix => 0,
749
+ :type_name => "RB_TEST_PKG",
750
+ :schema_name => @conn.username,
751
+ :sub_name => "REC1",
752
+ :link => "",
753
+ #:type_metadata => nil,
754
+ :arguments => {
755
+ :class => Array,
756
+ :size => 2,
757
+ [0] => {
758
+ :class => OCI8::Metadata::Argument,
759
+ :obj_name => nil,
760
+ :obj_schema => nil,
761
+ :name => "I",
762
+ :position => 1,
763
+ #:typecode => nil,
764
+ :data_type => 3,
765
+ :data_size => 0,
766
+ :precision => 0,
767
+ :scale => 0,
768
+ :level => 2,
769
+ :has_default => 0,
770
+ :has_default? => false,
771
+ :iomode => :in,
772
+ :radix => 0,
773
+ :type_name => "",
774
+ :schema_name => "",
775
+ :sub_name => "",
776
+ :link => "",
777
+ #:type_metadata => nil,
778
+ :arguments => [],
779
+ :inspect => '#<OCI8::Metadata::Argument: I unknown(3)>', # TODO: change to "PLS_INTEGER"
780
+ },
781
+ [1] => {
782
+ :class => OCI8::Metadata::Argument,
783
+ :obj_name => nil,
784
+ :obj_schema => nil,
785
+ :name => "J",
786
+ :position => 2,
787
+ #:typecode => nil,
788
+ :data_type => :number,
789
+ :data_size => 22,
790
+ :precision => 38,
791
+ :scale => 0,
792
+ :level => 2,
793
+ :has_default => 0,
794
+ :has_default? => false,
795
+ :iomode => :in,
796
+ :radix => 10,
797
+ :type_name => "",
798
+ :schema_name => "",
799
+ :sub_name => "",
800
+ :link => "",
801
+ #:type_metadata => nil,
802
+ :arguments => [],
803
+ :inspect => '#<OCI8::Metadata::Argument: J NUMBER(38)>', # TODO: change to "INTEGER"
804
+ },
805
+ },
806
+ :inspect => '#<OCI8::Metadata::Argument: unknown(250)>', # TODO: change to "#{@conn.username}.RB_TEST_PKG.REC1"
807
+ },
808
+ },
809
+ :inspect => "#<OCI8::Metadata::Argument: TBL #{@conn.username}.RB_TEST_PKG>", # TODO: change to "#{@conn.username}.RB_TEST_PKG.TABLE_OF_REC1"
810
+ },
811
+ },
812
+ :is_standalone? => false,
813
+ :inspect => '#<OCI8::Metadata::Function: ADD_REC1_VALUES>', # TODO: change to "#{@conn.username}.RB_TEST_PKG.ADD_REC1_VALUES"
814
+ }
815
+
816
+ out_rec1_values_subprogram_attrs = {
817
+ :class => OCI8::Metadata::Procedure,
818
+ :obj_name => 'OUT_REC1_VALUES',
819
+ :obj_schema => nil,
820
+ :is_invoker_rights? => false,
821
+ :name => 'OUT_REC1_VALUES',
822
+ :overload_id => 0,
823
+ :arguments => {
824
+ :class => Array,
825
+ :size => 1,
826
+ [0] => {
827
+ :class => OCI8::Metadata::Argument,
828
+ :obj_name => nil,
829
+ :obj_schema => nil,
830
+ :name => "TBL",
831
+ :position => 1,
832
+ #:typecode => nil,
833
+ :data_type => :named_type,
834
+ :data_size => 0,
835
+ :precision => 0,
836
+ :scale => 0,
837
+ :level => 0,
838
+ :has_default => 0,
839
+ :has_default? => false,
840
+ :iomode => :out,
841
+ :radix => 0,
842
+ :type_name => "RB_TEST_PKG",
843
+ :schema_name => @conn.username,
844
+ :sub_name => "TABLE_OF_REC1",
845
+ :link => "",
846
+ #:type_metadata => nil,
847
+ :arguments => {
848
+ :class => Array,
849
+ :size => 1,
850
+ [0] => {
851
+ :class => OCI8::Metadata::Argument,
852
+ :obj_name => nil,
853
+ :obj_schema => nil,
854
+ :name => "",
855
+ :position => 1,
856
+ #:typecode => nil,
857
+ :data_type => 250,
858
+ :data_size => 0,
859
+ :precision => 0,
860
+ :scale => 0,
861
+ :level => 1,
862
+ :has_default => 0,
863
+ :has_default? => false,
864
+ :iomode => :out,
865
+ :radix => 0,
866
+ :type_name => "RB_TEST_PKG",
867
+ :schema_name => @conn.username,
868
+ :sub_name => "REC1",
869
+ :link => "",
870
+ #:type_metadata => nil,
871
+ :arguments => {
872
+ :class => Array,
873
+ :size => 2,
874
+ [0] => {
875
+ :class => OCI8::Metadata::Argument,
876
+ :obj_name => nil,
877
+ :obj_schema => nil,
878
+ :name => "I",
879
+ :position => 1,
880
+ #:typecode => nil,
881
+ :data_type => 3,
882
+ :data_size => 0,
883
+ :precision => 0,
884
+ :scale => 0,
885
+ :level => 2,
886
+ :has_default => 0,
887
+ :has_default? => false,
888
+ :iomode => :out,
889
+ :radix => 0,
890
+ :type_name => "",
891
+ :schema_name => "",
892
+ :sub_name => "",
893
+ :link => "",
894
+ #:type_metadata => nil,
895
+ :arguments => [],
896
+ :inspect => '#<OCI8::Metadata::Argument: I unknown(3)>', # TODO: change to "PLS_INTEGER"
897
+ },
898
+ [1] => {
899
+ :class => OCI8::Metadata::Argument,
900
+ :obj_name => nil,
901
+ :obj_schema => nil,
902
+ :name => "J",
903
+ :position => 2,
904
+ #:typecode => nil,
905
+ :data_type => :number,
906
+ :data_size => 22,
907
+ :precision => 38,
908
+ :scale => 0,
909
+ :level => 2,
910
+ :has_default => 0,
911
+ :has_default? => false,
912
+ :iomode => :out,
913
+ :radix => 10,
914
+ :type_name => "",
915
+ :schema_name => "",
916
+ :sub_name => "",
917
+ :link => "",
918
+ #:type_metadata => nil,
919
+ :arguments => [],
920
+ :inspect => '#<OCI8::Metadata::Argument: J NUMBER(38)>', # TODO: change to "INTEGER"
921
+ },
922
+ },
923
+ :inspect => '#<OCI8::Metadata::Argument: unknown(250)>', # TODO: change to "#{@conn.username}.RB_TEST_PKG.REC1"
924
+ },
925
+ },
926
+ :inspect => "#<OCI8::Metadata::Argument: TBL #{@conn.username}.RB_TEST_PKG>", # TODO: change to "#{@conn.username}.RB_TEST_PKG.TABLE_OF_REC1"
927
+ },
928
+ },
929
+ :is_standalone? => false,
930
+ :inspect => '#<OCI8::Metadata::Procedure: OUT_REC1_VALUES>', # TODO: change to "#{@conn.username}.RB_TEST_PKG.OUT_REC1_VALUES"
931
+ }
932
+
933
+ subprogram_metadata_attrs = {
934
+ 'SUM_TABLE_OF_PLS_INTEGER' => sum_table_of_pls_integer_subprogram_attrs,
935
+ 'ADD_REC1_VALUES' => add_rec1_values_subprogram_attrs,
936
+ 'OUT_REC1_VALUES' => out_rec1_values_subprogram_attrs,
937
+ }
938
+
939
+ pkg_metadata = @conn.describe_package('rb_test_pkg')
940
+
941
+ assert_kind_of(OCI8::Metadata::Package, pkg_metadata)
942
+ assert_equal(false, pkg_metadata.is_invoker_rights?)
943
+ type_metadata = pkg_metadata.types
944
+ assert_kind_of(Array, type_metadata)
945
+ assert_equal(8, type_metadata.size)
946
+ type_metadata.each do |md|
947
+ attrs = type_metadata_attrs[md.name]
948
+ if attrs
949
+ check_attributes(md.name, md, attrs)
950
+ else
951
+ raise "unknown type name #{md.name}"
952
+ end
953
+ end
954
+
955
+ subprogram_metadata = pkg_metadata.subprograms
956
+ assert_kind_of(Array, subprogram_metadata)
957
+ assert_equal(3, subprogram_metadata.size)
958
+ subprogram_metadata.each do |md|
959
+ attrs = subprogram_metadata_attrs[md.name]
960
+ if attrs
961
+ check_attributes(md.name, md, attrs)
962
+ else
963
+ raise "unknown subprogram name #{md.name}"
964
+ end
965
+ end
966
+ end
967
+ end