ruby-plsql 0.5.0 → 0.5.1
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.
- checksums.yaml +7 -0
- data/Gemfile +8 -6
- data/History.txt +14 -0
- data/README.md +28 -5
- data/Rakefile +4 -3
- data/VERSION +1 -1
- data/lib/plsql/jdbc_connection.rb +6 -4
- data/lib/plsql/oci_connection.rb +10 -1
- data/lib/plsql/procedure.rb +23 -8
- data/lib/plsql/schema.rb +10 -1
- data/ruby-plsql.gemspec +24 -20
- data/spec/plsql/connection_spec.rb +97 -97
- data/spec/plsql/package_spec.rb +9 -9
- data/spec/plsql/procedure_spec.rb +192 -192
- data/spec/plsql/schema_spec.rb +47 -46
- data/spec/plsql/sequence_spec.rb +7 -7
- data/spec/plsql/sql_statements_spec.rb +10 -10
- data/spec/plsql/table_spec.rb +50 -50
- data/spec/plsql/type_spec.rb +40 -39
- data/spec/plsql/variable_spec.rb +52 -52
- data/spec/plsql/version_spec.rb +1 -1
- data/spec/plsql/view_spec.rb +41 -41
- data/spec/spec_helper.rb +40 -17
- metadata +73 -41
data/spec/plsql/package_spec.rb
CHANGED
@@ -32,25 +32,25 @@ describe "Package" do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should find existing package" do
|
35
|
-
PLSQL::Package.find(plsql, :test_package).
|
35
|
+
expect(PLSQL::Package.find(plsql, :test_package)).not_to be_nil
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should not find nonexisting package" do
|
39
|
-
PLSQL::Package.find(plsql, :qwerty123456).
|
39
|
+
expect(PLSQL::Package.find(plsql, :qwerty123456)).to be_nil
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should find existing package in schema" do
|
43
|
-
plsql.test_package.class.
|
43
|
+
expect(plsql.test_package.class).to eq(PLSQL::Package)
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should execute package function and return correct value" do
|
47
|
-
plsql.test_package.test_procedure('xxx').
|
47
|
+
expect(plsql.test_package.test_procedure('xxx')).to eq('XXX')
|
48
48
|
end
|
49
49
|
|
50
50
|
describe "variables" do
|
51
51
|
it "should set and get package variable value" do
|
52
52
|
plsql.test_package.test_variable = 1
|
53
|
-
plsql.test_package.test_variable.
|
53
|
+
expect(plsql.test_package.test_variable).to eq(1)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -85,11 +85,11 @@ describe "Synonym to package" do
|
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should find synonym to package" do
|
88
|
-
PLSQL::Package.find(plsql, :test_pkg_synonym).
|
88
|
+
expect(PLSQL::Package.find(plsql, :test_pkg_synonym)).not_to be_nil
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should execute package function using synonym and return correct value" do
|
92
|
-
plsql.test_pkg_synonym.test_procedure('xxx').
|
92
|
+
expect(plsql.test_pkg_synonym.test_procedure('xxx')).to eq('XXX')
|
93
93
|
end
|
94
94
|
|
95
95
|
end
|
@@ -105,11 +105,11 @@ describe "Public synonym to package" do
|
|
105
105
|
end
|
106
106
|
|
107
107
|
it "should find public synonym to package" do
|
108
|
-
PLSQL::Package.find(plsql, :utl_encode).
|
108
|
+
expect(PLSQL::Package.find(plsql, :utl_encode)).not_to be_nil
|
109
109
|
end
|
110
110
|
|
111
111
|
it "should execute package function using public synonym and return correct value" do
|
112
|
-
plsql.utl_encode.base64_encode('abc').
|
112
|
+
expect(plsql.utl_encode.base64_encode('abc')).to eq('4372773D')
|
113
113
|
end
|
114
114
|
|
115
115
|
end
|
@@ -23,35 +23,35 @@ describe "Parameter type mapping /" do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should find existing procedure" do
|
26
|
-
PLSQL::Procedure.find(plsql, :test_uppercase).
|
26
|
+
expect(PLSQL::Procedure.find(plsql, :test_uppercase)).not_to be_nil
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should not find nonexisting procedure" do
|
30
|
-
PLSQL::Procedure.find(plsql, :qwerty123456).
|
30
|
+
expect(PLSQL::Procedure.find(plsql, :qwerty123456)).to be_nil
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should execute function and return correct value" do
|
34
|
-
plsql.test_uppercase('xxx').
|
34
|
+
expect(plsql.test_uppercase('xxx')).to eq('XXX')
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should execute function with named parameters and return correct value" do
|
38
|
-
plsql.test_uppercase(:p_string => 'xxx').
|
38
|
+
expect(plsql.test_uppercase(:p_string => 'xxx')).to eq('XXX')
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should raise error if wrong number of arguments is passed" do
|
42
|
-
|
42
|
+
expect { plsql.test_uppercase('xxx','yyy') }.to raise_error(ArgumentError)
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should raise error if wrong named argument is passed" do
|
46
|
-
|
46
|
+
expect { plsql.test_uppercase(:p_string2 => 'xxx') }.to raise_error(ArgumentError)
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should execute function with schema name specified" do
|
50
|
-
plsql.hr.test_uppercase('xxx').
|
50
|
+
expect(plsql.hr.test_uppercase('xxx')).to eq('XXX')
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should process nil parameter as NULL" do
|
54
|
-
plsql.test_uppercase(nil).
|
54
|
+
expect(plsql.test_uppercase(nil)).to be_nil
|
55
55
|
end
|
56
56
|
|
57
57
|
end
|
@@ -104,35 +104,35 @@ describe "Parameter type mapping /" do
|
|
104
104
|
end
|
105
105
|
|
106
106
|
it "should process integer parameters" do
|
107
|
-
plsql.test_sum(123,456).
|
107
|
+
expect(plsql.test_sum(123,456)).to eq(579)
|
108
108
|
end
|
109
109
|
|
110
110
|
it "should process big integer parameters" do
|
111
|
-
plsql.test_sum(123123123123,456456456456).
|
111
|
+
expect(plsql.test_sum(123123123123,456456456456)).to eq(579579579579)
|
112
112
|
end
|
113
113
|
|
114
114
|
it "should process float parameters and return BigDecimal" do
|
115
|
-
plsql.test_sum(123.123,456.456).
|
115
|
+
expect(plsql.test_sum(123.123,456.456)).to eq(BigDecimal("579.579"))
|
116
116
|
end
|
117
117
|
|
118
118
|
it "should process BigDecimal parameters and return BigDecimal" do
|
119
|
-
plsql.test_sum(:p_num1 => BigDecimal("123.123"), :p_num2 => BigDecimal("456.456")).
|
119
|
+
expect(plsql.test_sum(:p_num1 => BigDecimal("123.123"), :p_num2 => BigDecimal("456.456"))).to eq(BigDecimal("579.579"))
|
120
120
|
end
|
121
121
|
|
122
122
|
it "should process nil parameter as NULL" do
|
123
|
-
plsql.test_sum(123,nil).
|
123
|
+
expect(plsql.test_sum(123,nil)).to be_nil
|
124
124
|
end
|
125
125
|
|
126
126
|
it "should convert true value to 1 for NUMBER parameter" do
|
127
|
-
plsql.test_number_1(true).
|
127
|
+
expect(plsql.test_number_1(true)).to eq('Y')
|
128
128
|
end
|
129
129
|
|
130
130
|
it "should convert false value to 0 for NUMBER parameter" do
|
131
|
-
plsql.test_number_1(false).
|
131
|
+
expect(plsql.test_number_1(false)).to eq('N')
|
132
132
|
end
|
133
133
|
|
134
134
|
it "should process binary integer parameters" do
|
135
|
-
plsql.test_integers(123, 456).
|
135
|
+
expect(plsql.test_integers(123, 456)).to eq({:x_pls_int => 123, :x_bin_int => 456})
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
@@ -162,45 +162,45 @@ describe "Parameter type mapping /" do
|
|
162
162
|
|
163
163
|
it "should process Time parameters" do
|
164
164
|
now = Time.local(2008,8,12,14,28,0)
|
165
|
-
plsql.test_date(now).
|
165
|
+
expect(plsql.test_date(now)).to eq(now + 60*60*24)
|
166
166
|
end
|
167
167
|
|
168
168
|
it "should process UTC Time parameters" do
|
169
169
|
plsql.default_timezone = :utc
|
170
170
|
now = Time.utc(2008,8,12,14,28,0)
|
171
|
-
plsql.test_date(now).
|
171
|
+
expect(plsql.test_date(now)).to eq(now + 60*60*24)
|
172
172
|
end
|
173
173
|
|
174
174
|
it "should process DateTime parameters" do
|
175
175
|
now = DateTime.parse(Time.local(2008,8,12,14,28,0).iso8601)
|
176
176
|
result = plsql.test_date(now)
|
177
|
-
result.class.
|
178
|
-
result.
|
177
|
+
expect(result.class).to eq(Time)
|
178
|
+
expect(result).to eq(Time.parse((now + 1).strftime("%c")))
|
179
179
|
end
|
180
180
|
|
181
181
|
it "should process old DateTime parameters" do
|
182
182
|
now = DateTime.civil(1901,1,1,12,0,0,plsql.local_timezone_offset)
|
183
183
|
result = plsql.test_date(now)
|
184
|
-
result.class.
|
185
|
-
result.
|
184
|
+
expect(result.class).to eq(Time)
|
185
|
+
expect(result).to eq(Time.parse((now + 1).strftime("%c")))
|
186
186
|
end
|
187
187
|
|
188
188
|
it "should process Date parameters" do
|
189
189
|
now = Date.new(2008,8,12)
|
190
190
|
result = plsql.test_date(now)
|
191
|
-
result.class.
|
192
|
-
result.
|
191
|
+
expect(result.class).to eq(Time)
|
192
|
+
expect(result).to eq(Time.parse((now + 1).strftime("%c")))
|
193
193
|
end
|
194
194
|
|
195
195
|
it "should process old Date parameters" do
|
196
196
|
now = Date.new(1901,1,1)
|
197
197
|
result = plsql.test_date(now)
|
198
|
-
result.class.
|
199
|
-
result.
|
198
|
+
expect(result.class).to eq(Time)
|
199
|
+
expect(result).to eq(Time.parse((now + 1).strftime("%c")))
|
200
200
|
end
|
201
201
|
|
202
202
|
it "should process nil date parameter as NULL" do
|
203
|
-
plsql.test_date(nil).
|
203
|
+
expect(plsql.test_date(nil)).to be_nil
|
204
204
|
end
|
205
205
|
|
206
206
|
end
|
@@ -227,7 +227,7 @@ describe "Parameter type mapping /" do
|
|
227
227
|
it "should process timestamp parameters" do
|
228
228
|
# now = Time.now
|
229
229
|
now = Time.local(2008,8,12,14,28,0)
|
230
|
-
plsql.test_timestamp(now).
|
230
|
+
expect(plsql.test_timestamp(now)).to eq(now + 60*60*24)
|
231
231
|
end
|
232
232
|
|
233
233
|
end
|
@@ -252,19 +252,19 @@ describe "Parameter type mapping /" do
|
|
252
252
|
end
|
253
253
|
|
254
254
|
it "should return hash with output parameters" do
|
255
|
-
plsql.test_copy("abc", nil, nil).
|
255
|
+
expect(plsql.test_copy("abc", nil, nil)).to eq({ :p_to => "abc", :p_to_double => "abcabc" })
|
256
256
|
end
|
257
257
|
|
258
258
|
it "should return hash with output parameters when called with named parameters" do
|
259
|
-
plsql.test_copy(:p_from => "abc", :p_to => nil, :p_to_double => nil).
|
259
|
+
expect(plsql.test_copy(:p_from => "abc", :p_to => nil, :p_to_double => nil)).to eq({ :p_to => "abc", :p_to_double => "abcabc" })
|
260
260
|
end
|
261
261
|
|
262
262
|
it "should substitute output parameters with nil if they are not specified" do
|
263
|
-
plsql.test_copy("abc").
|
263
|
+
expect(plsql.test_copy("abc")).to eq({ :p_to => "abc", :p_to_double => "abcabc" })
|
264
264
|
end
|
265
265
|
|
266
266
|
it "should substitute named output parameters with nil if they are not specified" do
|
267
|
-
plsql.test_copy(:p_from => "abc").
|
267
|
+
expect(plsql.test_copy(:p_from => "abc")).to eq({ :p_to => "abc", :p_to_double => "abcabc" })
|
268
268
|
end
|
269
269
|
|
270
270
|
end
|
@@ -335,46 +335,46 @@ describe "Parameter type mapping /" do
|
|
335
335
|
end
|
336
336
|
|
337
337
|
it "should find existing package" do
|
338
|
-
PLSQL::Package.find(plsql, :test_package2).
|
338
|
+
expect(PLSQL::Package.find(plsql, :test_package2)).not_to be_nil
|
339
339
|
end
|
340
340
|
|
341
341
|
it "should identify overloaded procedure definition" do
|
342
342
|
@procedure = PLSQL::Procedure.find(plsql, :test_procedure, "TEST_PACKAGE2")
|
343
|
-
@procedure.
|
344
|
-
@procedure.
|
343
|
+
expect(@procedure).not_to be_nil
|
344
|
+
expect(@procedure).to be_overloaded
|
345
345
|
end
|
346
346
|
|
347
347
|
it "should identify non-overloaded procedure definition" do
|
348
348
|
@procedure = PLSQL::Procedure.find(plsql, :test_procedure2, "TEST_PACKAGE2")
|
349
|
-
@procedure.
|
350
|
-
@procedure.
|
349
|
+
expect(@procedure).not_to be_nil
|
350
|
+
expect(@procedure).not_to be_overloaded
|
351
351
|
end
|
352
352
|
|
353
353
|
it "should execute correct procedures based on number of arguments and return correct value" do
|
354
|
-
plsql.test_package2.test_procedure('xxx').
|
355
|
-
plsql.test_package2.test_procedure('xxx', nil).
|
354
|
+
expect(plsql.test_package2.test_procedure('xxx')).to eq('XXX')
|
355
|
+
expect(plsql.test_package2.test_procedure('xxx', nil)).to eq({:p_result => 'XXX'})
|
356
356
|
end
|
357
357
|
|
358
358
|
it "should execute correct procedures based on number of named arguments and return correct value" do
|
359
|
-
plsql.test_package2.test_procedure(:p_string => 'xxx').
|
360
|
-
plsql.test_package2.test_procedure(:p_string => 'xxx', :p_result => nil).
|
359
|
+
expect(plsql.test_package2.test_procedure(:p_string => 'xxx')).to eq('XXX')
|
360
|
+
expect(plsql.test_package2.test_procedure(:p_string => 'xxx', :p_result => nil)).to eq({:p_result => 'XXX'})
|
361
361
|
end
|
362
362
|
|
363
363
|
it "should raise exception if procedure cannot be found based on number of arguments" do
|
364
|
-
|
364
|
+
expect { plsql.test_package2.test_procedure() }.to raise_error(/wrong number or types of arguments/i)
|
365
365
|
end
|
366
366
|
|
367
367
|
it "should find procedure based on types of arguments" do
|
368
|
-
plsql.test_package2.test_procedure(111, nil).
|
368
|
+
expect(plsql.test_package2.test_procedure(111, nil)).to eq({:p_result => '111'})
|
369
369
|
end
|
370
370
|
|
371
371
|
it "should find procedure based on names of named arguments" do
|
372
|
-
plsql.test_package2.test_procedure(:p_number => 111, :p_result => nil).
|
372
|
+
expect(plsql.test_package2.test_procedure(:p_number => 111, :p_result => nil)).to eq({:p_result => '111'})
|
373
373
|
end
|
374
374
|
|
375
375
|
it "should find matching procedure based on partial list of named arguments" do
|
376
|
-
plsql.test_package2.test_function(:p_string => 'xxx').
|
377
|
-
plsql.test_package2.test_function(:p_number => 1).
|
376
|
+
expect(plsql.test_package2.test_function(:p_string => 'xxx')).to eq('xxx ')
|
377
|
+
expect(plsql.test_package2.test_function(:p_number => 1)).to eq(2)
|
378
378
|
end
|
379
379
|
|
380
380
|
end
|
@@ -401,16 +401,17 @@ describe "Parameter type mapping /" do
|
|
401
401
|
end
|
402
402
|
|
403
403
|
it "should return array with return value and hash of output parameters" do
|
404
|
-
plsql.test_copy_function("abc", nil, nil).
|
404
|
+
expect(plsql.test_copy_function("abc", nil, nil)).to eq([3, { :p_to => "abc", :p_to_double => "abcabc" }])
|
405
405
|
end
|
406
406
|
|
407
407
|
it "should return array with return value and hash of output parameters when called with named parameters" do
|
408
|
-
plsql.test_copy_function(:p_from => "abc", :p_to => nil, :p_to_double => nil).
|
408
|
+
expect(plsql.test_copy_function(:p_from => "abc", :p_to => nil, :p_to_double => nil)).to eq(
|
409
409
|
[3, { :p_to => "abc", :p_to_double => "abcabc" }]
|
410
|
+
)
|
410
411
|
end
|
411
412
|
|
412
413
|
it "should substitute output parameters with nil if they are not specified" do
|
413
|
-
plsql.test_copy_function("abc").
|
414
|
+
expect(plsql.test_copy_function("abc")).to eq([3, { :p_to => "abc", :p_to_double => "abcabc" }])
|
414
415
|
end
|
415
416
|
|
416
417
|
end
|
@@ -442,19 +443,19 @@ describe "Parameter type mapping /" do
|
|
442
443
|
end
|
443
444
|
|
444
445
|
it "should find function" do
|
445
|
-
PLSQL::Procedure.find(plsql, :test_no_params).
|
446
|
+
expect(PLSQL::Procedure.find(plsql, :test_no_params)).not_to be_nil
|
446
447
|
end
|
447
448
|
|
448
449
|
it "should return function value" do
|
449
|
-
plsql.test_no_params.
|
450
|
+
expect(plsql.test_no_params).to eq("dummy")
|
450
451
|
end
|
451
452
|
|
452
453
|
it "should find procedure" do
|
453
|
-
PLSQL::Procedure.find(plsql, :test_proc_no_params).
|
454
|
+
expect(PLSQL::Procedure.find(plsql, :test_proc_no_params)).not_to be_nil
|
454
455
|
end
|
455
456
|
|
456
457
|
it "should execute procedure" do
|
457
|
-
plsql.test_proc_no_params.
|
458
|
+
expect(plsql.test_proc_no_params).to be_nil
|
458
459
|
end
|
459
460
|
|
460
461
|
end
|
@@ -503,41 +504,41 @@ describe "Parameter type mapping /" do
|
|
503
504
|
end
|
504
505
|
|
505
506
|
it "should find existing procedure" do
|
506
|
-
PLSQL::Procedure.find(plsql, :test_clob).
|
507
|
+
expect(PLSQL::Procedure.find(plsql, :test_clob)).not_to be_nil
|
507
508
|
end
|
508
509
|
|
509
510
|
it "should execute function and return correct value" do
|
510
511
|
large_text = 'ābčdēfghij' * 10_000
|
511
|
-
plsql.test_clob(large_text).
|
512
|
+
expect(plsql.test_clob(large_text)).to eq(large_text)
|
512
513
|
end
|
513
514
|
|
514
515
|
unless defined?(JRUBY_VERSION)
|
515
516
|
|
516
517
|
it "should execute function with empty string and return nil (oci8 cannot pass empty CLOB parameter)" do
|
517
518
|
text = ''
|
518
|
-
plsql.test_clob(text).
|
519
|
+
expect(plsql.test_clob(text)).to be_nil
|
519
520
|
end
|
520
521
|
|
521
522
|
it "should execute function which inserts the CLOB parameter into a table with empty string and return nil" do
|
522
523
|
text = ''
|
523
|
-
plsql.test_clob_insert(text).
|
524
|
+
expect(plsql.test_clob_insert(text)).to be_nil
|
524
525
|
end
|
525
526
|
|
526
527
|
else
|
527
528
|
|
528
529
|
it "should execute function with empty string and return empty string" do
|
529
530
|
text = ''
|
530
|
-
plsql.test_clob(text).
|
531
|
+
expect(plsql.test_clob(text)).to eq(text)
|
531
532
|
end
|
532
533
|
|
533
534
|
end
|
534
535
|
|
535
536
|
it "should execute function with nil and return nil" do
|
536
|
-
plsql.test_clob(nil).
|
537
|
+
expect(plsql.test_clob(nil)).to be_nil
|
537
538
|
end
|
538
539
|
|
539
540
|
it "should execute function which inserts the CLOB parameter into a table with nil and return nil" do
|
540
|
-
plsql.test_clob_insert(nil).
|
541
|
+
expect(plsql.test_clob_insert(nil)).to be_nil
|
541
542
|
end
|
542
543
|
|
543
544
|
end
|
@@ -562,12 +563,12 @@ describe "Parameter type mapping /" do
|
|
562
563
|
end
|
563
564
|
|
564
565
|
it "should find existing procedure" do
|
565
|
-
PLSQL::Procedure.find(plsql, :test_clob_proc).
|
566
|
+
expect(PLSQL::Procedure.find(plsql, :test_clob_proc)).not_to be_nil
|
566
567
|
end
|
567
568
|
|
568
569
|
it "should execute function and return correct value" do
|
569
570
|
large_text = 'ābčdēfghij' * 10_000
|
570
|
-
plsql.test_clob_proc(large_text)[:p_return].
|
571
|
+
expect(plsql.test_clob_proc(large_text)[:p_return]).to eq(large_text)
|
571
572
|
end
|
572
573
|
end
|
573
574
|
|
@@ -591,12 +592,12 @@ describe "Parameter type mapping /" do
|
|
591
592
|
end
|
592
593
|
|
593
594
|
it "should find existing procedure" do
|
594
|
-
PLSQL::Procedure.find(plsql, :test_blob_proc).
|
595
|
+
expect(PLSQL::Procedure.find(plsql, :test_blob_proc)).not_to be_nil
|
595
596
|
end
|
596
597
|
|
597
598
|
it "should execute function and return correct value" do
|
598
599
|
large_binary = '\000\001\002\003\004\005\006\007\010\011' * 10_000
|
599
|
-
plsql.test_blob_proc(large_binary)[:p_return].
|
600
|
+
expect(plsql.test_blob_proc(large_binary)[:p_return]).to eq(large_binary)
|
600
601
|
end
|
601
602
|
end
|
602
603
|
|
@@ -712,41 +713,41 @@ describe "Parameter type mapping /" do
|
|
712
713
|
end
|
713
714
|
|
714
715
|
it "should find existing function" do
|
715
|
-
PLSQL::Procedure.find(plsql, :test_full_name).
|
716
|
+
expect(PLSQL::Procedure.find(plsql, :test_full_name)).not_to be_nil
|
716
717
|
end
|
717
718
|
|
718
719
|
it "should execute function with named parameter and return correct value" do
|
719
|
-
plsql.test_full_name(:p_employee => @p_employee).
|
720
|
+
expect(plsql.test_full_name(:p_employee => @p_employee)).to eq('First Last')
|
720
721
|
end
|
721
722
|
|
722
723
|
it "should execute function with sequential parameter and return correct value" do
|
723
|
-
plsql.test_full_name(@p_employee).
|
724
|
+
expect(plsql.test_full_name(@p_employee)).to eq('First Last')
|
724
725
|
end
|
725
726
|
|
726
727
|
it "should execute function with Hash parameter using strings as keys" do
|
727
|
-
plsql.test_full_name(@p_employee2).
|
728
|
+
expect(plsql.test_full_name(@p_employee2)).to eq('Second Last')
|
728
729
|
end
|
729
730
|
|
730
731
|
it "should raise error if wrong field name is passed for record parameter" do
|
731
|
-
|
732
|
-
plsql.test_full_name(@p_employee.merge :xxx => 'xxx').
|
733
|
-
end.
|
732
|
+
expect do
|
733
|
+
expect(plsql.test_full_name(@p_employee.merge :xxx => 'xxx')).to eq('Second Last')
|
734
|
+
end.to raise_error(ArgumentError)
|
734
735
|
end
|
735
736
|
|
736
737
|
it "should return empty table of records" do
|
737
|
-
plsql.test_record.test_empty_records().
|
738
|
+
expect(plsql.test_record.test_empty_records()).to eq([])
|
738
739
|
end
|
739
740
|
|
740
741
|
it "should return record return value" do
|
741
|
-
plsql.test_employee_record(@p_employee).
|
742
|
+
expect(plsql.test_employee_record(@p_employee)).to eq(@p_employee)
|
742
743
|
end
|
743
744
|
|
744
745
|
it "should return record return value and output record parameter value" do
|
745
|
-
plsql.test_employee_record2(@p_employee, @p_employee2).
|
746
|
+
expect(plsql.test_employee_record2(@p_employee, @p_employee2)).to eq([@p_employee, {:x_employee => @p_employee}])
|
746
747
|
end
|
747
748
|
|
748
749
|
it "should execute package function with parameter with record type defined in package" do
|
749
|
-
plsql.test_record.test_full_name(@p_employee).
|
750
|
+
expect(plsql.test_record.test_full_name(@p_employee)).to eq('First Last')
|
750
751
|
end
|
751
752
|
|
752
753
|
end
|
@@ -780,27 +781,27 @@ describe "Parameter type mapping /" do
|
|
780
781
|
end
|
781
782
|
|
782
783
|
it "should accept true value and return true value" do
|
783
|
-
plsql.test_boolean(true).
|
784
|
+
expect(plsql.test_boolean(true)).to eq(true)
|
784
785
|
end
|
785
786
|
|
786
787
|
it "should accept false value and return false value" do
|
787
|
-
plsql.test_boolean(false).
|
788
|
+
expect(plsql.test_boolean(false)).to eq(false)
|
788
789
|
end
|
789
790
|
|
790
791
|
it "should accept nil value and return nil value" do
|
791
|
-
plsql.test_boolean(nil).
|
792
|
+
expect(plsql.test_boolean(nil)).to be_nil
|
792
793
|
end
|
793
794
|
|
794
795
|
it "should accept true value and assign true value to output parameter" do
|
795
|
-
plsql.test_boolean2(true, nil).
|
796
|
+
expect(plsql.test_boolean2(true, nil)).to eq({:x_boolean => true})
|
796
797
|
end
|
797
798
|
|
798
799
|
it "should accept false value and assign false value to output parameter" do
|
799
|
-
plsql.test_boolean2(false, nil).
|
800
|
+
expect(plsql.test_boolean2(false, nil)).to eq({:x_boolean => false})
|
800
801
|
end
|
801
802
|
|
802
803
|
it "should accept nil value and assign nil value to output parameter" do
|
803
|
-
plsql.test_boolean2(nil, nil).
|
804
|
+
expect(plsql.test_boolean2(nil, nil)).to eq({:x_boolean => nil})
|
804
805
|
end
|
805
806
|
|
806
807
|
end
|
@@ -883,33 +884,33 @@ describe "Parameter type mapping /" do
|
|
883
884
|
end
|
884
885
|
|
885
886
|
it "should find existing function" do
|
886
|
-
PLSQL::Procedure.find(plsql, :test_full_name).
|
887
|
+
expect(PLSQL::Procedure.find(plsql, :test_full_name)).not_to be_nil
|
887
888
|
end
|
888
889
|
|
889
890
|
it "should execute function with named parameter and return correct value" do
|
890
|
-
plsql.test_full_name(:p_employee => @p_employee).
|
891
|
+
expect(plsql.test_full_name(:p_employee => @p_employee)).to eq('First Last')
|
891
892
|
end
|
892
893
|
|
893
894
|
it "should execute function with sequential parameter and return correct value" do
|
894
|
-
plsql.test_full_name(@p_employee).
|
895
|
+
expect(plsql.test_full_name(@p_employee)).to eq('First Last')
|
895
896
|
end
|
896
897
|
|
897
898
|
it "should raise error if wrong field name is passed for record parameter" do
|
898
|
-
|
899
|
+
expect do
|
899
900
|
plsql.test_full_name(@p_employee.merge :xxx => 'xxx')
|
900
|
-
end.
|
901
|
+
end.to raise_error(ArgumentError)
|
901
902
|
end
|
902
903
|
|
903
904
|
it "should return object type return value" do
|
904
|
-
plsql.test_employee_object(@p_employee).
|
905
|
+
expect(plsql.test_employee_object(@p_employee)).to eq(@p_employee)
|
905
906
|
end
|
906
907
|
|
907
908
|
it "should return object type return value and output object type parameter value" do
|
908
|
-
plsql.test_employee_object2(@p_employee, nil).
|
909
|
+
expect(plsql.test_employee_object2(@p_employee, nil)).to eq([@p_employee, {:x_employee => @p_employee}])
|
909
910
|
end
|
910
911
|
|
911
912
|
it "should accept NULL as input parameter" do
|
912
|
-
plsql.test_employee_object(nil).
|
913
|
+
expect(plsql.test_employee_object(nil)).to eq(nil)
|
913
914
|
end
|
914
915
|
|
915
916
|
end
|
@@ -1149,83 +1150,83 @@ describe "Parameter type mapping /" do
|
|
1149
1150
|
end
|
1150
1151
|
|
1151
1152
|
it "should find existing function" do
|
1152
|
-
PLSQL::Procedure.find(plsql, :test_sum).
|
1153
|
+
expect(PLSQL::Procedure.find(plsql, :test_sum)).not_to be_nil
|
1153
1154
|
end
|
1154
1155
|
|
1155
1156
|
it "should execute function with number array parameter" do
|
1156
|
-
plsql.test_sum([1,2,3,4]).
|
1157
|
+
expect(plsql.test_sum([1,2,3,4])).to eq(10)
|
1157
1158
|
end
|
1158
1159
|
|
1159
1160
|
it "should return number array return value" do
|
1160
|
-
plsql.test_increment([1,2,3,4], 1).
|
1161
|
+
expect(plsql.test_increment([1,2,3,4], 1)).to eq([2,3,4,5])
|
1161
1162
|
end
|
1162
1163
|
|
1163
1164
|
it "should execute function with string array and return string array output parameter" do
|
1164
1165
|
strings = ['1','2','3','4']
|
1165
|
-
plsql.test_copy_strings(strings).
|
1166
|
+
expect(plsql.test_copy_strings(strings)).to eq([strings, {:x_strings => strings}])
|
1166
1167
|
end
|
1167
1168
|
|
1168
1169
|
it "should execute function with table of numbers type (defined inside package) parameter" do
|
1169
|
-
plsql.test_collections.test_sum([1,2,3,4]).
|
1170
|
+
expect(plsql.test_collections.test_sum([1,2,3,4])).to eq(10)
|
1170
1171
|
end
|
1171
1172
|
|
1172
1173
|
it "should clear temporary tables after executing function with table of numbers type even if an error occurs in the package" do
|
1173
1174
|
# this should work fine
|
1174
|
-
plsql.test_collections.test_function_failure([1,2,3,4], 'N').
|
1175
|
+
expect(plsql.test_collections.test_function_failure([1,2,3,4], 'N')).to eq(4)
|
1175
1176
|
# we will force a package error here to see if things get cleaned up before the next call
|
1176
|
-
|
1177
|
+
expect { plsql.test_collections.test_function_failure([1,2,3,4], 'Y') }.to raise_error(/Simulate business error to test clearing of temp table/)
|
1177
1178
|
# after the error in the first call temporary tables should be cleared
|
1178
|
-
plsql.test_collections.test_function_failure([5,6,7], 'N').
|
1179
|
+
expect(plsql.test_collections.test_function_failure([5,6,7], 'N')).to eq(3)
|
1179
1180
|
end
|
1180
1181
|
|
1181
1182
|
it "should return table of numbers type (defined inside package)" do
|
1182
|
-
plsql.test_collections.test_numbers([1,2,3,4]).
|
1183
|
+
expect(plsql.test_collections.test_numbers([1,2,3,4])).to eq([[1,2,3,4], {:x_numbers => [1,2,3,4]}])
|
1183
1184
|
end
|
1184
1185
|
|
1185
1186
|
it "should clear temporary tables after executing function with table of numbers type (defined inside package) parameter" do
|
1186
|
-
plsql.test_collections.test_numbers([1,2,3,4]).
|
1187
|
+
expect(plsql.test_collections.test_numbers([1,2,3,4])).to eq([[1,2,3,4], {:x_numbers => [1,2,3,4]}])
|
1187
1188
|
# after first call temporary tables should be cleared
|
1188
|
-
plsql.test_collections.test_numbers([1,2,3,4]).
|
1189
|
+
expect(plsql.test_collections.test_numbers([1,2,3,4])).to eq([[1,2,3,4], {:x_numbers => [1,2,3,4]}])
|
1189
1190
|
end
|
1190
1191
|
|
1191
1192
|
it "should clear temporary tables when autocommit with table of numbers type (defined inside package) parameter" do
|
1192
1193
|
old_autocommit = plsql.connection.autocommit?
|
1193
1194
|
plsql.connection.autocommit = true
|
1194
1195
|
numbers_array = (1..400).to_a
|
1195
|
-
plsql.test_collections.test_numbers(numbers_array).
|
1196
|
+
expect(plsql.test_collections.test_numbers(numbers_array)).to eq([numbers_array, {:x_numbers => numbers_array}])
|
1196
1197
|
# after first call temporary tables should be cleared
|
1197
|
-
plsql.test_collections.test_numbers(numbers_array).
|
1198
|
+
expect(plsql.test_collections.test_numbers(numbers_array)).to eq([numbers_array, {:x_numbers => numbers_array}])
|
1198
1199
|
plsql.connection.autocommit = old_autocommit
|
1199
1200
|
end
|
1200
1201
|
|
1201
1202
|
it "should execute function with table of records type (defined inside package) parameter" do
|
1202
|
-
plsql.test_collections.test_employees(@employees).
|
1203
|
+
expect(plsql.test_collections.test_employees(@employees)).to eq([@employees, {:p_employees => @employees}])
|
1203
1204
|
end
|
1204
1205
|
|
1205
1206
|
it "should execute function with table of records type (defined inside package and includes NVARCHAR columns) parameter" do
|
1206
|
-
plsql.test_collections.test_nstring(@nstrings).
|
1207
|
+
expect(plsql.test_collections.test_nstring(@nstrings)).to eq([(1..5).map{|i| "NCh #{i}NStr #{i},"}.join, {:p_out => @nstrings}])
|
1207
1208
|
end
|
1208
1209
|
|
1209
1210
|
it "should execute function with object array and return object array output parameter" do
|
1210
1211
|
phones = [{:type => 'mobile', :phone_number => '123456'}, {:type => 'home', :phone_number => '654321'}]
|
1211
|
-
plsql.test_copy_objects(phones).
|
1212
|
+
expect(plsql.test_copy_objects(phones)).to eq([phones, {:x_phones => phones}])
|
1212
1213
|
end
|
1213
1214
|
|
1214
1215
|
it "should execute function with empty object array" do
|
1215
1216
|
phones = []
|
1216
|
-
plsql.test_copy_objects(phones).
|
1217
|
+
expect(plsql.test_copy_objects(phones)).to eq([phones, {:x_phones => phones}])
|
1217
1218
|
end
|
1218
1219
|
|
1219
1220
|
it "should raise error with record parameter that has table as element" do
|
1220
|
-
|
1221
|
-
plsql.test_collections.test_employee2(@employees[0]).
|
1222
|
-
}.
|
1221
|
+
expect {
|
1222
|
+
expect(plsql.test_collections.test_employee2(@employees[0])).to eq([@employees[0], {:p_employee => @employees[0]}])
|
1223
|
+
}.to raise_error(ArgumentError, /TEST_COLLECTIONS\.T_NUMBERS definition inside package is not supported/)
|
1223
1224
|
end
|
1224
1225
|
|
1225
1226
|
it "should raise error with table of records parameter when record has table as element" do
|
1226
|
-
|
1227
|
-
plsql.test_collections.test_employees2(@employees).
|
1228
|
-
}.
|
1227
|
+
expect {
|
1228
|
+
expect(plsql.test_collections.test_employees2(@employees)).to eq([@employees, {:p_employees => @employees}])
|
1229
|
+
}.to raise_error(ArgumentError, /TEST_COLLECTIONS\.T_NUMBERS definition inside package is not supported/)
|
1229
1230
|
end
|
1230
1231
|
|
1231
1232
|
end
|
@@ -1355,37 +1356,37 @@ describe "Parameter type mapping /" do
|
|
1355
1356
|
|
1356
1357
|
it "should clear temporary tables after executing function with index-by table of numbers type even if an error occurs in the package" do
|
1357
1358
|
# this should work fine
|
1358
|
-
plsql.test_collections.test_function_failure(@numbers, 'N').
|
1359
|
+
expect(plsql.test_collections.test_function_failure(@numbers, 'N')).to eq(10)
|
1359
1360
|
# we will force a package error here to see if things get cleaned up before the next call
|
1360
|
-
|
1361
|
+
expect { plsql.test_collections.test_function_failure(@numbers, 'Y') }.to raise_error(/Simulate business error to test clearing of temp table/)
|
1361
1362
|
# after the error in the first call temporary tables should be cleared
|
1362
|
-
plsql.test_collections.test_function_failure(@numbers2, 'N').
|
1363
|
+
expect(plsql.test_collections.test_function_failure(@numbers2, 'N')).to eq(18)
|
1363
1364
|
end
|
1364
1365
|
|
1365
1366
|
it "should execute function with index-by table of numbers type (defined inside package) parameter" do
|
1366
|
-
plsql.test_collections.test_sum(@numbers).
|
1367
|
+
expect(plsql.test_collections.test_sum(@numbers)).to eq(10)
|
1367
1368
|
end
|
1368
1369
|
|
1369
1370
|
it "should return index-by table of numbers type (defined inside package)" do
|
1370
|
-
plsql.test_collections.test_numbers(@numbers).
|
1371
|
+
expect(plsql.test_collections.test_numbers(@numbers)).to eq([@numbers, {:x_numbers => @numbers}])
|
1371
1372
|
end
|
1372
1373
|
|
1373
1374
|
it "should clear temporary tables when autocommit with index-by table of numbers type (defined inside package) parameter" do
|
1374
1375
|
old_autocommit = plsql.connection.autocommit?
|
1375
1376
|
plsql.connection.autocommit = true
|
1376
1377
|
numbers_hash = Hash[*(1..400).map{|i|[i,i]}.flatten]
|
1377
|
-
plsql.test_collections.test_numbers(numbers_hash).
|
1378
|
+
expect(plsql.test_collections.test_numbers(numbers_hash)).to eq([numbers_hash, {:x_numbers => numbers_hash}])
|
1378
1379
|
# after first call temporary tables should be cleared
|
1379
|
-
plsql.test_collections.test_numbers(numbers_hash).
|
1380
|
+
expect(plsql.test_collections.test_numbers(numbers_hash)).to eq([numbers_hash, {:x_numbers => numbers_hash}])
|
1380
1381
|
plsql.connection.autocommit = old_autocommit
|
1381
1382
|
end
|
1382
1383
|
|
1383
1384
|
it "should execute function with index-by table of records type (defined inside package) parameter" do
|
1384
|
-
plsql.test_collections.test_employees(@employees).
|
1385
|
+
expect(plsql.test_collections.test_employees(@employees)).to eq([@employees, {:p_employees => @employees}])
|
1385
1386
|
end
|
1386
1387
|
|
1387
1388
|
it "should execute procedure with index-by table of records type (defined inside package) parameter" do
|
1388
|
-
plsql.test_collections.test_employees_prc(@employees).
|
1389
|
+
expect(plsql.test_collections.test_employees_prc(@employees)).to eq({:p_employees => @employees})
|
1389
1390
|
end
|
1390
1391
|
|
1391
1392
|
it "should create temporary tables in autonomous transaction" do
|
@@ -1395,23 +1396,23 @@ describe "Parameter type mapping /" do
|
|
1395
1396
|
# procedure call should not commit initial insert
|
1396
1397
|
plsql.test_collections.insert_employees(2=>@employees[2], 3=>@employees[3])
|
1397
1398
|
plsql.rollback
|
1398
|
-
plsql.test_employees.all.
|
1399
|
+
expect(plsql.test_employees.all).to be_empty
|
1399
1400
|
plsql.connection.autocommit = old_autocommit
|
1400
1401
|
end
|
1401
1402
|
|
1402
1403
|
describe "using Oracle 9.2" do
|
1403
|
-
before
|
1404
|
+
before do
|
1404
1405
|
# simulate Oracle 9.2 connection
|
1405
1406
|
plsql(:oracle_9).connection = get_connection
|
1406
|
-
plsql(:oracle_9).connection.
|
1407
|
+
allow(plsql(:oracle_9).connection).to receive(:database_version).and_return([9, 2, 0, 0])
|
1407
1408
|
end
|
1408
1409
|
|
1409
|
-
after
|
1410
|
+
after do
|
1410
1411
|
plsql(:oracle_9).logoff
|
1411
1412
|
end
|
1412
1413
|
|
1413
1414
|
it "should create temporary tables when using Oracle 9.2" do
|
1414
|
-
plsql(:oracle_9).test_collections.test_numbers(@numbers).
|
1415
|
+
expect(plsql(:oracle_9).test_collections.test_numbers(@numbers)).to eq([@numbers, {:x_numbers => @numbers}])
|
1415
1416
|
end
|
1416
1417
|
|
1417
1418
|
end
|
@@ -1510,30 +1511,30 @@ describe "Parameter type mapping /" do
|
|
1510
1511
|
end
|
1511
1512
|
|
1512
1513
|
it "should find existing function" do
|
1513
|
-
PLSQL::Procedure.find(plsql, :test_sum).
|
1514
|
+
expect(PLSQL::Procedure.find(plsql, :test_sum)).not_to be_nil
|
1514
1515
|
end
|
1515
1516
|
|
1516
1517
|
it "should execute function with number array parameter" do
|
1517
|
-
plsql.test_sum([1,2,3,4]).
|
1518
|
+
expect(plsql.test_sum([1,2,3,4])).to eq(10)
|
1518
1519
|
end
|
1519
1520
|
|
1520
1521
|
it "should return number array return value" do
|
1521
|
-
plsql.test_increment([1,2,3,4], 1).
|
1522
|
+
expect(plsql.test_increment([1,2,3,4], 1)).to eq([2,3,4,5])
|
1522
1523
|
end
|
1523
1524
|
|
1524
1525
|
it "should execute function with string array and return string array output parameter" do
|
1525
1526
|
strings = ['1','2','3','4']
|
1526
|
-
plsql.test_copy_strings(strings).
|
1527
|
+
expect(plsql.test_copy_strings(strings)).to eq([strings, {:x_strings => strings}])
|
1527
1528
|
end
|
1528
1529
|
|
1529
1530
|
it "should execute function with object array and return object array output parameter" do
|
1530
1531
|
phones = [{:type => 'mobile', :phone_number => '123456'}, {:type => 'home', :phone_number => '654321'}]
|
1531
|
-
plsql.test_copy_objects(phones).
|
1532
|
+
expect(plsql.test_copy_objects(phones)).to eq([phones, {:x_phones => phones}])
|
1532
1533
|
end
|
1533
1534
|
|
1534
1535
|
it "should execute function with empty object array" do
|
1535
1536
|
phones = []
|
1536
|
-
plsql.test_copy_objects(phones).
|
1537
|
+
expect(plsql.test_copy_objects(phones)).to eq([phones, {:x_phones => phones}])
|
1537
1538
|
end
|
1538
1539
|
|
1539
1540
|
end
|
@@ -1643,30 +1644,30 @@ describe "Parameter type mapping /" do
|
|
1643
1644
|
end
|
1644
1645
|
|
1645
1646
|
it "should execute function with number array parameter" do
|
1646
|
-
plsql.test_collections.test_sum([1,2,3,4]).
|
1647
|
+
expect(plsql.test_collections.test_sum([1,2,3,4])).to eq(10)
|
1647
1648
|
end
|
1648
1649
|
|
1649
1650
|
it "should clear temporary tables after executing function with varray of numbers type even if an error occurs in the package" do
|
1650
1651
|
# this should work fine
|
1651
|
-
plsql.test_collections.test_function_failure([1,2,3,4], 'N').
|
1652
|
+
expect(plsql.test_collections.test_function_failure([1,2,3,4], 'N')).to eq(10)
|
1652
1653
|
# we will force a package error here to see if things get cleaned up before the next call
|
1653
|
-
|
1654
|
+
expect { plsql.test_collections.test_function_failure([5,6,7], 'Y') }.to raise_error(/Simulate business error to test clearing of temp table/)
|
1654
1655
|
# after the error in the first call temporary tables should be cleared
|
1655
|
-
plsql.test_collections.test_function_failure([3,4,5,6], 'N').
|
1656
|
+
expect(plsql.test_collections.test_function_failure([3,4,5,6], 'N')).to eq(18)
|
1656
1657
|
end
|
1657
1658
|
|
1658
1659
|
it "should return number array return value" do
|
1659
|
-
plsql.test_collections.test_increment([1,2,3,4], 1).
|
1660
|
+
expect(plsql.test_collections.test_increment([1,2,3,4], 1)).to eq([2,3,4,5])
|
1660
1661
|
end
|
1661
1662
|
|
1662
1663
|
it "should execute function with string array and return string array output parameter" do
|
1663
1664
|
strings = ['1','2','3','4']
|
1664
|
-
plsql.test_collections.test_copy_strings(strings).
|
1665
|
+
expect(plsql.test_collections.test_copy_strings(strings)).to eq([strings, {:x_strings => strings}])
|
1665
1666
|
end
|
1666
1667
|
|
1667
1668
|
it "should execute function with object array and return object array output parameter" do
|
1668
1669
|
phones = [{:type => 'mobile', :phone_number => '123456'}, {:type => 'home', :phone_number => '654321'}]
|
1669
|
-
plsql.test_collections.test_copy_objects(phones).
|
1670
|
+
expect(plsql.test_collections.test_copy_objects(phones)).to eq([phones, {:x_phones => phones}])
|
1670
1671
|
end
|
1671
1672
|
|
1672
1673
|
# This test fails without wcmatthysen's "Procedure-call Fix." pull request.
|
@@ -1751,72 +1752,71 @@ describe "Parameter type mapping /" do
|
|
1751
1752
|
end
|
1752
1753
|
|
1753
1754
|
it "should find existing function" do
|
1754
|
-
PLSQL::Procedure.find(plsql, :test_cursor).
|
1755
|
+
expect(PLSQL::Procedure.find(plsql, :test_cursor)).not_to be_nil
|
1755
1756
|
end
|
1756
1757
|
|
1757
1758
|
it "should return cursor and fetch first row" do
|
1758
|
-
plsql.test_cursor do |cursor|
|
1759
|
-
cursor.fetch.
|
1760
|
-
end.
|
1759
|
+
expect(plsql.test_cursor do |cursor|
|
1760
|
+
expect(cursor.fetch).to eq(@fields.map{|f| @employees[0][f]})
|
1761
|
+
end).to be_nil
|
1761
1762
|
end
|
1762
1763
|
|
1763
1764
|
it "should close all returned cursors after block is executed" do
|
1764
1765
|
cursor2 = nil
|
1765
|
-
plsql.test_cursor do |cursor|
|
1766
|
+
expect(plsql.test_cursor do |cursor|
|
1766
1767
|
cursor2 = cursor
|
1767
|
-
end.
|
1768
|
-
|
1768
|
+
end).to be_nil
|
1769
|
+
expect { cursor2.fetch }.to raise_error
|
1769
1770
|
end
|
1770
1771
|
|
1771
1772
|
it "should not raise error if cursor is closed inside block" do
|
1772
|
-
|
1773
|
+
expect do
|
1773
1774
|
plsql.test_cursor do |cursor|
|
1774
1775
|
cursor.close
|
1775
1776
|
end
|
1776
|
-
end.
|
1777
|
+
end.not_to raise_error
|
1777
1778
|
end
|
1778
1779
|
|
1779
1780
|
it "should fetch hash from returned cursor" do
|
1780
1781
|
plsql.test_cursor do |cursor|
|
1781
|
-
cursor.fetch_hash.
|
1782
|
+
expect(cursor.fetch_hash).to eq(@employees[0])
|
1782
1783
|
end
|
1783
1784
|
end
|
1784
1785
|
|
1785
1786
|
it "should fetch all rows from returned cursor" do
|
1786
1787
|
plsql.test_cursor do |cursor|
|
1787
|
-
cursor.fetch_all.
|
1788
|
+
expect(cursor.fetch_all).to eq(@employees.map{|e| @fields.map{|f| e[f]}})
|
1788
1789
|
end
|
1789
1790
|
end
|
1790
1791
|
|
1791
1792
|
it "should fetch all rows as hash from returned cursor" do
|
1792
1793
|
plsql.test_cursor do |cursor|
|
1793
|
-
cursor.fetch_hash_all.
|
1794
|
+
expect(cursor.fetch_hash_all).to eq(@employees)
|
1794
1795
|
end
|
1795
1796
|
end
|
1796
1797
|
|
1797
1798
|
it "should get field names from returned cursor" do
|
1798
1799
|
plsql.test_cursor do |cursor|
|
1799
|
-
cursor.fields.
|
1800
|
+
expect(cursor.fields).to eq(@fields)
|
1800
1801
|
end
|
1801
1802
|
end
|
1802
1803
|
|
1803
1804
|
it "should return output parameter with cursor and fetch first row" do
|
1804
|
-
plsql.test_cursor_out do |result|
|
1805
|
-
result[:x_cursor].fetch.
|
1806
|
-
end.
|
1805
|
+
expect(plsql.test_cursor_out do |result|
|
1806
|
+
expect(result[:x_cursor].fetch).to eq(@fields.map{|f| @employees[0][f]})
|
1807
|
+
end).to be_nil
|
1807
1808
|
end
|
1808
1809
|
|
1809
1810
|
it "should return output parameter with cursor and fetch all rows as hash" do
|
1810
|
-
plsql.test_cursor_out do |result|
|
1811
|
-
result[:x_cursor].fetch_hash_all.
|
1812
|
-
end.
|
1811
|
+
expect(plsql.test_cursor_out do |result|
|
1812
|
+
expect(result[:x_cursor].fetch_hash_all).to eq(@employees)
|
1813
|
+
end).to be_nil
|
1813
1814
|
end
|
1814
1815
|
|
1815
1816
|
it "should execute function with cursor parameter and return record" do
|
1816
|
-
|
1817
|
-
pending "fails with core dump with ruby-oci8 2.1.0" if OCI8::VERSION >= "2.1.0"
|
1817
|
+
skip "not possible from JDBC" if defined?(JRUBY_VERSION)
|
1818
1818
|
plsql.test_cursor do |cursor|
|
1819
|
-
plsql.test_cursor_fetch(cursor).
|
1819
|
+
expect(plsql.test_cursor_fetch(cursor)).to eq(@employees[0])
|
1820
1820
|
end
|
1821
1821
|
end
|
1822
1822
|
|
@@ -1866,20 +1866,20 @@ describe "Parameter type mapping /" do
|
|
1866
1866
|
end
|
1867
1867
|
|
1868
1868
|
it "should return cursor and fetch first row" do
|
1869
|
-
plsql.typed_ref_cursor_test.get_all do |cursor|
|
1870
|
-
cursor.fetch.
|
1871
|
-
end.
|
1869
|
+
expect(plsql.typed_ref_cursor_test.get_all do |cursor|
|
1870
|
+
expect(cursor.fetch).to eq(@rows[0])
|
1871
|
+
end).to be_nil
|
1872
1872
|
end
|
1873
1873
|
|
1874
1874
|
it "should fetch hash from returned cursor" do
|
1875
1875
|
plsql.typed_ref_cursor_test.get_all do |cursor|
|
1876
|
-
cursor.fetch_hash.
|
1876
|
+
expect(cursor.fetch_hash).to eq(Hash[*@fields.zip(@rows[0]).flatten])
|
1877
1877
|
end
|
1878
1878
|
end
|
1879
1879
|
|
1880
1880
|
it "should fetch all rows from returned cursor" do
|
1881
1881
|
plsql.typed_ref_cursor_test.get_all do |cursor|
|
1882
|
-
cursor.fetch_all.
|
1882
|
+
expect(cursor.fetch_all).to eq(@rows)
|
1883
1883
|
end
|
1884
1884
|
end
|
1885
1885
|
|
@@ -1917,11 +1917,11 @@ describe "Synonyms /" do
|
|
1917
1917
|
end
|
1918
1918
|
|
1919
1919
|
it "should find synonym to function" do
|
1920
|
-
PLSQL::Procedure.find(plsql, :test_synonym).
|
1920
|
+
expect(PLSQL::Procedure.find(plsql, :test_synonym)).not_to be_nil
|
1921
1921
|
end
|
1922
1922
|
|
1923
1923
|
it "should execute function using synonym and return correct value" do
|
1924
|
-
plsql.test_synonym('xxx').
|
1924
|
+
expect(plsql.test_synonym('xxx')).to eq('XXX')
|
1925
1925
|
end
|
1926
1926
|
|
1927
1927
|
end
|
@@ -1944,15 +1944,15 @@ describe "Synonyms /" do
|
|
1944
1944
|
end
|
1945
1945
|
|
1946
1946
|
it "should find public synonym to function" do
|
1947
|
-
PLSQL::Procedure.find(plsql, :ora_login_user).
|
1947
|
+
expect(PLSQL::Procedure.find(plsql, :ora_login_user)).not_to be_nil
|
1948
1948
|
end
|
1949
1949
|
|
1950
1950
|
it "should execute function using public synonym and return correct value" do
|
1951
|
-
plsql.ora_login_user.
|
1951
|
+
expect(plsql.ora_login_user).to eq('HR')
|
1952
1952
|
end
|
1953
1953
|
|
1954
1954
|
it "should not find public synonym if schema prefix is used" do
|
1955
|
-
|
1955
|
+
expect { plsql.hr.ora_login_user }.to raise_error(ArgumentError)
|
1956
1956
|
end
|
1957
1957
|
|
1958
1958
|
it "should find private synonym before public synonym" do
|
@@ -1960,10 +1960,10 @@ describe "Synonyms /" do
|
|
1960
1960
|
plsql.connection = get_connection
|
1961
1961
|
plsql.execute "DROP SYNONYM ora_login_user" rescue nil
|
1962
1962
|
plsql.execute "CREATE SYNONYM ora_login_user FOR hr.test_ora_login_user"
|
1963
|
-
plsql.ora_login_user.
|
1963
|
+
expect(plsql.ora_login_user).to eq('XXX')
|
1964
1964
|
plsql.execute "DROP SYNONYM ora_login_user"
|
1965
1965
|
plsql.connection = get_connection
|
1966
|
-
plsql.ora_login_user.
|
1966
|
+
expect(plsql.ora_login_user).to eq('HR')
|
1967
1967
|
end
|
1968
1968
|
|
1969
1969
|
end
|
@@ -2000,15 +2000,15 @@ describe "Synonyms /" do
|
|
2000
2000
|
end
|
2001
2001
|
|
2002
2002
|
it "should raise error when invalid function is called" do
|
2003
|
-
|
2003
|
+
expect {
|
2004
2004
|
plsql.test_invalid_function('test')
|
2005
|
-
}.
|
2005
|
+
}.to raise_error(ArgumentError, /is not in valid status/)
|
2006
2006
|
end
|
2007
2007
|
|
2008
2008
|
it "should raise error when function from invalid package body is called" do
|
2009
|
-
|
2009
|
+
expect {
|
2010
2010
|
plsql.test_invalid_package.test_invalid_function('test')
|
2011
|
-
}.
|
2011
|
+
}.to raise_error(ArgumentError, /body is not in valid status/)
|
2012
2012
|
end
|
2013
2013
|
end
|
2014
2014
|
|
@@ -2025,24 +2025,24 @@ describe "SYS.STANDARD procedures /" do
|
|
2025
2025
|
end
|
2026
2026
|
|
2027
2027
|
it "should execute function from SYS.STANDARD package" do
|
2028
|
-
plsql.upper('abc').
|
2028
|
+
expect(plsql.upper('abc')).to eq('ABC')
|
2029
2029
|
end
|
2030
2030
|
|
2031
2031
|
it "should find function overload based on types of sequential arguments" do
|
2032
|
-
plsql.nvl(1, 2).
|
2033
|
-
plsql.nvl(nil, 2).
|
2034
|
-
plsql.nvl(1.1, 2.2).
|
2035
|
-
plsql.nvl(nil, 2.2).
|
2036
|
-
plsql.nvl(BigDecimal('1.1'), BigDecimal('2.2')).
|
2037
|
-
plsql.nvl(nil, BigDecimal('2.2')).
|
2038
|
-
plsql.nvl('a', 'b').
|
2039
|
-
plsql.nvl(nil, 'b').
|
2040
|
-
plsql.nvl(Date.new(2010,1,13), Date.new(2010,1,19)).
|
2041
|
-
plsql.nvl(nil, Date.new(2010,1,19)).
|
2042
|
-
plsql.nvl(Time.local(2010,1,13), Time.local(2010,1,19)).
|
2043
|
-
plsql.nvl(nil, Time.local(2010,1,19)).
|
2044
|
-
plsql.nvl(true, false).
|
2045
|
-
plsql.nvl(nil, false).
|
2032
|
+
expect(plsql.nvl(1, 2)).to eq(1)
|
2033
|
+
expect(plsql.nvl(nil, 2)).to eq(2)
|
2034
|
+
expect(plsql.nvl(1.1, 2.2)).to eq(1.1)
|
2035
|
+
expect(plsql.nvl(nil, 2.2)).to eq(2.2)
|
2036
|
+
expect(plsql.nvl(BigDecimal('1.1'), BigDecimal('2.2'))).to eq(BigDecimal('1.1'))
|
2037
|
+
expect(plsql.nvl(nil, BigDecimal('2.2'))).to eq(BigDecimal('2.2'))
|
2038
|
+
expect(plsql.nvl('a', 'b')).to eq('a')
|
2039
|
+
expect(plsql.nvl(nil, 'b')).to eq('b')
|
2040
|
+
expect(plsql.nvl(Date.new(2010,1,13), Date.new(2010,1,19))).to eq(Time.local(2010,1,13))
|
2041
|
+
expect(plsql.nvl(nil, Date.new(2010,1,19))).to eq(Time.local(2010,1,19))
|
2042
|
+
expect(plsql.nvl(Time.local(2010,1,13), Time.local(2010,1,19))).to eq(Time.local(2010,1,13))
|
2043
|
+
expect(plsql.nvl(nil, Time.local(2010,1,19))).to eq(Time.local(2010,1,19))
|
2044
|
+
expect(plsql.nvl(true, false)).to eq(true)
|
2045
|
+
expect(plsql.nvl(nil, false)).to eq(false)
|
2046
2046
|
end
|
2047
2047
|
|
2048
2048
|
end
|