ruby-plsql 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/History.txt +2 -0
  3. data/VERSION +1 -1
  4. data/lib/plsql/connection.rb +14 -14
  5. data/lib/plsql/helpers.rb +3 -3
  6. data/lib/plsql/jdbc_connection.rb +3 -3
  7. data/lib/plsql/oci_connection.rb +8 -4
  8. data/lib/plsql/package.rb +3 -3
  9. data/lib/plsql/procedure.rb +32 -17
  10. data/lib/plsql/procedure_call.rb +15 -15
  11. data/lib/plsql/schema.rb +13 -9
  12. data/lib/plsql/sequence.rb +2 -2
  13. data/lib/plsql/table.rb +6 -6
  14. data/lib/plsql/type.rb +7 -7
  15. data/lib/plsql/variable.rb +4 -4
  16. data/lib/plsql/version.rb +1 -1
  17. data/lib/plsql/view.rb +2 -2
  18. metadata +13 -138
  19. data/.github/stale.yml +0 -37
  20. data/.github/workflows/rubocop.yml +0 -37
  21. data/.github/workflows/test.yml +0 -69
  22. data/.rubocop.yml +0 -147
  23. data/.travis/oracle/download.sh +0 -15
  24. data/.travis/oracle/install.sh +0 -32
  25. data/.travis/setup_accounts.sh +0 -9
  26. data/.travis.yml +0 -88
  27. data/Gemfile +0 -24
  28. data/Rakefile +0 -53
  29. data/Vagrantfile +0 -38
  30. data/ci/network/admin/tnsnames.ora +0 -7
  31. data/ci/setup_accounts.sh +0 -9
  32. data/gemfiles/Gemfile.activerecord-5.0 +0 -21
  33. data/gemfiles/Gemfile.activerecord-5.1 +0 -21
  34. data/gemfiles/Gemfile.activerecord-5.2 +0 -21
  35. data/gemfiles/Gemfile.activerecord-6.0 +0 -21
  36. data/gemfiles/Gemfile.activerecord-6.1 +0 -21
  37. data/gemfiles/Gemfile.activerecord-main +0 -21
  38. data/ruby-plsql.gemspec +0 -114
  39. data/spec/plsql/connection_spec.rb +0 -505
  40. data/spec/plsql/package_spec.rb +0 -172
  41. data/spec/plsql/procedure_spec.rb +0 -2390
  42. data/spec/plsql/schema_spec.rb +0 -364
  43. data/spec/plsql/sequence_spec.rb +0 -67
  44. data/spec/plsql/sql_statements_spec.rb +0 -91
  45. data/spec/plsql/table_spec.rb +0 -376
  46. data/spec/plsql/type_spec.rb +0 -299
  47. data/spec/plsql/variable_spec.rb +0 -497
  48. data/spec/plsql/version_spec.rb +0 -8
  49. data/spec/plsql/view_spec.rb +0 -264
  50. data/spec/spec.opts +0 -6
  51. data/spec/spec_helper.rb +0 -121
  52. data/spec/support/create_arunit_user.sql +0 -2
  53. data/spec/support/custom_config.rb.sample +0 -14
  54. data/spec/support/file_check_script.sh +0 -9
  55. data/spec/support/test_db.rb +0 -149
  56. data/spec/support/unlock_and_setup_hr_user.sql +0 -2
@@ -1,497 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require "spec_helper"
4
-
5
- describe "Package variables /" do
6
-
7
- describe "String" do
8
- before(:all) do
9
- plsql.connect! CONNECTION_PARAMS
10
- plsql.execute <<-SQL
11
- CREATE OR REPLACE PACKAGE test_package IS
12
- varchar2_variable VARCHAR2(50);
13
- varchar2_variable2 VARCHAR2(50); -- some comment
14
- varchar2_default varchar2(50) := 'default' ;
15
- varchar2_default2 varchar2(50) DEFAULT 'default';
16
- varchar2_default3 varchar2(50) NOT NULL := 'default';
17
- varchar2_3_char VARCHAR2(3 CHAR);
18
- varchar2_3_byte VARCHAR2(3 BYTE);
19
- varchar_variable VARCHAR(50);
20
- char_variable char(10) ;
21
- nvarchar2_variable NVARCHAR2(50);
22
- nchar_variable NCHAR(10);
23
- END;
24
- SQL
25
- plsql.execute <<-SQL
26
- CREATE OR REPLACE PACKAGE BODY test_package IS
27
- END;
28
- SQL
29
-
30
- end
31
-
32
- after(:all) do
33
- plsql.execute "DROP PACKAGE test_package"
34
- plsql.logoff
35
- end
36
-
37
- it "should set and get VARCHAR variable" do
38
- plsql.test_package.varchar_variable = "abc"
39
- expect(plsql.test_package.varchar_variable).to eq("abc")
40
- end
41
-
42
- it "should set and get VARCHAR2 variable" do
43
- plsql.test_package.varchar2_variable = "abc"
44
- expect(plsql.test_package.varchar2_variable).to eq("abc")
45
- end
46
-
47
- it "should set and get VARCHAR2 variable with comment" do
48
- plsql.test_package.varchar2_variable2 = "abc"
49
- expect(plsql.test_package.varchar2_variable2).to eq("abc")
50
- end
51
-
52
- it "should get VARCHAR2 variable default value" do
53
- expect(plsql.test_package.varchar2_default).to eq("default")
54
- expect(plsql.test_package.varchar2_default2).to eq("default")
55
- expect(plsql.test_package.varchar2_default3).to eq("default")
56
- end
57
-
58
- describe "with character or byte limit" do
59
- before(:each) do
60
- if !defined?(JRUBY_VERSION) && OCI8.properties.has_key?(:length_semantics)
61
- @original_length_semantics = OCI8.properties[:length_semantics]
62
- OCI8.properties[:length_semantics] = :char
63
- end
64
- end
65
-
66
- after(:each) do
67
- if !defined?(JRUBY_VERSION) && OCI8.properties.has_key?(:length_semantics)
68
- OCI8.properties[:length_semantics] = @original_length_semantics
69
- end
70
- end
71
-
72
- it "should set and get VARCHAR2(n CHAR) variable" do
73
- plsql.test_package.varchar2_3_char = "āčē"
74
- expect(plsql.test_package.varchar2_3_char).to eq("āčē")
75
- expect { plsql.test_package.varchar2_3_char = "aceg" }.to raise_error(/buffer too small/)
76
- end
77
-
78
- it "should set and get VARCHAR2(n BYTE) variable" do
79
- plsql.test_package.varchar2_3_byte = "ace"
80
- expect(plsql.test_package.varchar2_3_byte).to eq("ace")
81
- expect { plsql.test_package.varchar2_3_byte = "āce" }.to raise_error(/buffer too small/)
82
- expect { plsql.test_package.varchar2_3_byte = "aceg" }.to raise_error(/buffer too small/)
83
- end
84
-
85
- end
86
-
87
- it "should set and get CHAR variable" do
88
- plsql.test_package.char_variable = "abc"
89
- expect(plsql.test_package.char_variable).to eq("abc" + " " * 7)
90
- end
91
-
92
- it "should set and get NVARCHAR2 variable" do
93
- plsql.test_package.nvarchar2_variable = "abc"
94
- expect(plsql.test_package.nvarchar2_variable).to eq("abc")
95
- end
96
-
97
- it "should set and get NCHAR variable" do
98
- plsql.test_package.nchar_variable = "abc"
99
- expect(plsql.test_package.nchar_variable).to eq("abc" + " " * 7)
100
- end
101
-
102
- end
103
-
104
- shared_examples "Numeric" do |ora_data_type, default, class_, given, expected|
105
-
106
- before(:all) do
107
- plsql.connect! CONNECTION_PARAMS
108
- plsql.execute <<-SQL
109
- CREATE OR REPLACE PACKAGE test_package IS
110
- numeric_var #{ora_data_type}#{default ? ':= ' + default.to_s : nil};
111
- END;
112
- SQL
113
- end
114
-
115
- after(:all) do
116
- plsql.execute "DROP PACKAGE test_package"
117
- plsql.logoff
118
- end
119
-
120
- it "should get #{ora_data_type} variable default value" do
121
- expect(plsql.test_package.numeric_var).to eq(default)
122
- end if default
123
-
124
- it "should get #{ora_data_type} variable type mapped to #{class_.to_s}" do
125
- plsql.test_package.numeric_var = given
126
- expect(plsql.test_package.numeric_var).to be_a class_
127
- end
128
-
129
- it "should set and get #{ora_data_type} variable" do
130
- plsql.test_package.numeric_var = given
131
- expect(plsql.test_package.numeric_var).to eq(expected)
132
- end
133
-
134
- end
135
-
136
- [
137
- { ora_data_type: "INTEGER", default: nil, class: Integer, given: 1, expected: 1 },
138
- { ora_data_type: "NUMBER(10)", default: nil, class: Integer, given: 1, expected: 1 },
139
- { ora_data_type: "NUMBER(10)", default: 5, class: Integer, given: 1, expected: 1 },
140
- { ora_data_type: "NUMBER", default: nil, class: BigDecimal, given: 123.456, expected: 123.456 },
141
- { ora_data_type: "NUMBER(15,2)", default: nil, class: BigDecimal, given: 123.456, expected: 123.46 },
142
- { ora_data_type: "PLS_INTEGER", default: nil, class: Integer, given: 1, expected: 1 },
143
- { ora_data_type: "BINARY_INTEGER", default: nil, class: Integer, given: 1, expected: 1 },
144
- { ora_data_type: "SIMPLE_INTEGER", default: 10, class: Integer, given: 1, expected: 1 },
145
- { ora_data_type: "NATURAL", default: nil, class: Integer, given: 1, expected: 1 },
146
- { ora_data_type: "NATURALN", default: 0, class: Integer, given: 1, expected: 1 },
147
- { ora_data_type: "POSITIVE", default: nil, class: Integer, given: 1, expected: 1 },
148
- { ora_data_type: "POSITIVEN", default: 5, class: Integer, given: 1, expected: 1 },
149
- { ora_data_type: "SIGNTYPE", default: -1, class: Integer, given: 1, expected: 1 },
150
- ].each do |row|
151
- ora_data_type, default, class_, given, expected = row.values
152
- describe ora_data_type + (default ? " with default" : "") do
153
- include_examples "Numeric", ora_data_type, default, class_, given, expected
154
- end
155
- end
156
-
157
- describe "Date and Time" do
158
- before(:all) do
159
- plsql.connect! CONNECTION_PARAMS
160
- plsql.execute <<-SQL
161
- CREATE OR REPLACE PACKAGE test_package IS
162
- date_variable DATE;
163
- date_default DATE := TO_DATE('2009-12-21', 'YYYY-MM-DD');
164
- timestamp_variable TIMESTAMP;
165
- timestamptz_variable TIMESTAMP WITH TIME ZONE;
166
- timestampltz_variable TIMESTAMP WITH LOCAL TIME ZONE;
167
- END;
168
- SQL
169
- plsql.execute <<-SQL
170
- CREATE OR REPLACE PACKAGE BODY test_package IS
171
- END;
172
- SQL
173
- @date = Time.local(2009, 12, 21)
174
- @timestamp = Time.local(2009, 12, 21, 14, 10, 30, 11)
175
- end
176
-
177
- after(:all) do
178
- plsql.execute "DROP PACKAGE test_package"
179
- plsql.logoff
180
- end
181
-
182
- it "should set and get DATE variable" do
183
- plsql.test_package.date_variable = @date
184
- expect(plsql.test_package.date_variable).to be_a Time
185
- expect(plsql.test_package.date_variable).to eq(@date)
186
- end
187
-
188
- it "should get DATE variable default value" do
189
- expect(plsql.test_package.date_default).to eq(@date)
190
- end
191
-
192
- it "should set and get TIMESTAMP variable" do
193
- plsql.test_package.timestamp_variable = @timestamp
194
- expect(plsql.test_package.timestamp_variable).to be_a Time
195
- expect(plsql.test_package.timestamp_variable).to eq(@timestamp)
196
- end
197
-
198
- it "should set and get TIMESTAMP WITH TIME ZONE variable" do
199
- plsql.test_package.timestamptz_variable = @timestamp
200
- expect(plsql.test_package.timestamptz_variable).to be_a Time
201
- expect(plsql.test_package.timestamptz_variable).to eq(@timestamp)
202
- end
203
-
204
- it "should set and get TIMESTAMP WITH LOCAL TIME ZONE variable" do
205
- plsql.test_package.timestampltz_variable = @timestamp
206
- expect(plsql.test_package.timestampltz_variable).to be_a Time
207
- expect(plsql.test_package.timestampltz_variable).to eq(@timestamp)
208
- end
209
-
210
- end
211
-
212
- describe "LOB" do
213
- before(:all) do
214
- plsql.connect! CONNECTION_PARAMS
215
- plsql.execute <<-SQL
216
- CREATE OR REPLACE PACKAGE test_package IS
217
- clob_variable CLOB;
218
- clob_default CLOB := 'default';
219
- nclob_variable CLOB;
220
- blob_variable BLOB;
221
- END;
222
- SQL
223
- plsql.execute <<-SQL
224
- CREATE OR REPLACE PACKAGE BODY test_package IS
225
- END;
226
- SQL
227
-
228
- end
229
-
230
- after(:all) do
231
- plsql.execute "DROP PACKAGE test_package"
232
- plsql.logoff
233
- end
234
-
235
- it "should set and get CLOB variable" do
236
- plsql.test_package.clob_variable = "abc"
237
- expect(plsql.test_package.clob_variable).to eq("abc")
238
- end
239
-
240
- it "should get CLOB variable default value" do
241
- expect(plsql.test_package.clob_default).to eq("default")
242
- end
243
-
244
- it "should set and get NCLOB variable" do
245
- plsql.test_package.nclob_variable = "abc"
246
- expect(plsql.test_package.nclob_variable).to eq("abc")
247
- end
248
-
249
- it "should set and get BLOB variable" do
250
- plsql.test_package.blob_variable = "\000\001\003"
251
- expect(plsql.test_package.blob_variable).to eq("\000\001\003")
252
- end
253
-
254
- end
255
-
256
- describe "table column type" do
257
- before(:all) do
258
- plsql.connect! CONNECTION_PARAMS
259
- plsql.execute <<-SQL
260
- CREATE TABLE test_employees (
261
- employee_id NUMBER(15),
262
- first_name VARCHAR2(50),
263
- last_name VARCHAR2(50),
264
- hire_date DATE
265
- )
266
- SQL
267
-
268
- plsql.execute <<-SQL
269
- CREATE OR REPLACE PACKAGE test_package IS
270
- employee_id test_employees.employee_id%TYPE;
271
- first_name test_employees.first_name%TYPE;
272
- hire_date test_employees.hire_date%TYPE;
273
- END;
274
- SQL
275
- plsql.execute <<-SQL
276
- CREATE OR REPLACE PACKAGE BODY test_package IS
277
- END;
278
- SQL
279
-
280
- end
281
-
282
- after(:all) do
283
- plsql.execute "DROP PACKAGE test_package"
284
- plsql.execute "DROP TABLE test_employees"
285
- plsql.logoff
286
- end
287
-
288
- it "should set and get NUMBER variable" do
289
- plsql.test_package.employee_id = 1
290
- expect(plsql.test_package.employee_id).to eq(1)
291
- end
292
-
293
- it "should set and get VARCHAR2 variable" do
294
- plsql.test_package.first_name = "First"
295
- expect(plsql.test_package.first_name).to eq("First")
296
- end
297
-
298
- it "should set and get DATE variable" do
299
- today = Time.local(2009, 12, 22)
300
- plsql.test_package.hire_date = today
301
- expect(plsql.test_package.hire_date).to eq(today)
302
- end
303
-
304
- end
305
-
306
- describe "constants" do
307
- before(:all) do
308
- plsql.connect! CONNECTION_PARAMS
309
- plsql.execute <<-SQL
310
- CREATE OR REPLACE PACKAGE test_package IS
311
- integer_constant CONSTANT NUMBER(1) := 1;
312
- string_constant CONSTANT VARCHAR2(10) := 'constant';
313
- END;
314
- SQL
315
- plsql.execute <<-SQL
316
- CREATE OR REPLACE PACKAGE BODY test_package IS
317
- END;
318
- SQL
319
-
320
- end
321
-
322
- after(:all) do
323
- plsql.execute "DROP PACKAGE test_package"
324
- plsql.logoff
325
- end
326
-
327
- it "should get NUMBER constant" do
328
- expect(plsql.test_package.integer_constant).to eq(1)
329
- end
330
-
331
- it "should get VARCHAR2 constant" do
332
- expect(plsql.test_package.string_constant).to eq("constant")
333
- end
334
-
335
- it "should raise error when trying to set constant" do
336
- expect {
337
- plsql.test_package.integer_constant = 2
338
- }.to raise_error(/PLS-00363/)
339
- end
340
-
341
- end
342
-
343
- describe "object type" do
344
- before(:all) do
345
- plsql.connect! CONNECTION_PARAMS
346
- plsql.execute "DROP TYPE t_employee" rescue nil
347
- plsql.execute "DROP TYPE t_phones" rescue nil
348
- plsql.execute <<-SQL
349
- CREATE OR REPLACE TYPE t_address AS OBJECT (
350
- street VARCHAR2(50),
351
- city VARCHAR2(50),
352
- country VARCHAR2(50)
353
- )
354
- SQL
355
- plsql.execute <<-SQL
356
- CREATE OR REPLACE TYPE t_phone AS OBJECT (
357
- type VARCHAR2(10),
358
- phone_number VARCHAR2(50)
359
- )
360
- SQL
361
- plsql.execute <<-SQL
362
- CREATE OR REPLACE TYPE t_phones AS TABLE OF T_PHONE
363
- SQL
364
- plsql.execute <<-SQL
365
- CREATE OR REPLACE TYPE t_employee AS OBJECT (
366
- employee_id NUMBER(15),
367
- first_name VARCHAR2(50),
368
- last_name VARCHAR2(50),
369
- hire_date DATE,
370
- address t_address,
371
- phones t_phones
372
- )
373
- SQL
374
- @phones = [{ type: "mobile", phone_number: "123456" }, { type: "home", phone_number: "654321" }]
375
- @employee = {
376
- employee_id: 1,
377
- first_name: "First",
378
- last_name: "Last",
379
- hire_date: Time.local(2000, 01, 31),
380
- address: { street: "Main street 1", city: "Riga", country: "Latvia" },
381
- phones: @phones
382
- }
383
-
384
- plsql.execute <<-SQL
385
- CREATE OR REPLACE PACKAGE test_package IS
386
- g_employee t_employee;
387
- g_employee2 hr.t_employee;
388
- g_phones t_phones;
389
- END;
390
- SQL
391
- plsql.execute <<-SQL
392
- CREATE OR REPLACE PACKAGE BODY test_package IS
393
- END;
394
- SQL
395
-
396
- end
397
-
398
- after(:all) do
399
- plsql.execute "DROP PACKAGE test_package"
400
- plsql.execute "DROP TYPE t_employee"
401
- plsql.execute "DROP TYPE t_address"
402
- plsql.execute "DROP TYPE t_phones"
403
- plsql.execute "DROP TYPE t_phone"
404
- plsql.logoff
405
- end
406
-
407
- it "should set and get object type variable" do
408
- plsql.test_package.g_employee = @employee
409
- expect(plsql.test_package.g_employee).to eq(@employee)
410
- end
411
-
412
- it "should set and get object type variable when schema prefix is used with type" do
413
- plsql.hr.test_package.g_employee2 = @employee
414
- expect(plsql.hr.test_package.g_employee2).to eq(@employee)
415
- end
416
-
417
- it "should set and get collection type variable" do
418
- plsql.test_package.g_phones = @phones
419
- expect(plsql.test_package.g_phones).to eq(@phones)
420
- end
421
-
422
- end
423
-
424
- describe "table row type" do
425
- before(:all) do
426
- plsql.connect! CONNECTION_PARAMS
427
- plsql.execute <<-SQL
428
- CREATE TABLE test_employees (
429
- employee_id NUMBER(15),
430
- first_name VARCHAR2(50),
431
- last_name VARCHAR2(50),
432
- hire_date DATE
433
- )
434
- SQL
435
- @employee = {
436
- employee_id: 1,
437
- first_name: "First",
438
- last_name: "Last",
439
- hire_date: Time.local(2000, 01, 31)
440
- }
441
-
442
- plsql.execute <<-SQL
443
- CREATE OR REPLACE PACKAGE test_package IS
444
- g_employee test_employees%ROWTYPE;
445
- END;
446
- SQL
447
- plsql.execute <<-SQL
448
- CREATE OR REPLACE PACKAGE BODY test_package IS
449
- END;
450
- SQL
451
-
452
- end
453
-
454
- after(:all) do
455
- plsql.execute "DROP PACKAGE test_package"
456
- plsql.execute "DROP TABLE test_employees"
457
- plsql.logoff
458
- end
459
-
460
- it "should set and get table ROWTYPE variable" do
461
- plsql.test_package.g_employee = @employee
462
- expect(plsql.test_package.g_employee).to eq(@employee)
463
- end
464
-
465
- end
466
-
467
- describe "booleans" do
468
- before(:all) do
469
- plsql.connect! CONNECTION_PARAMS
470
- plsql.execute <<-SQL
471
- CREATE OR REPLACE PACKAGE test_package IS
472
- boolean_variable BOOLEAN;
473
- END;
474
- SQL
475
- plsql.execute <<-SQL
476
- CREATE OR REPLACE PACKAGE BODY test_package IS
477
- END;
478
- SQL
479
-
480
- end
481
-
482
- after(:all) do
483
- plsql.execute "DROP PACKAGE test_package"
484
- plsql.logoff
485
- end
486
-
487
- it "should set and get BOOLEAN variable" do
488
- expect(plsql.test_package.boolean_variable).to be_nil
489
- plsql.test_package.boolean_variable = true
490
- expect(plsql.test_package.boolean_variable).to be_truthy
491
- plsql.test_package.boolean_variable = false
492
- expect(plsql.test_package.boolean_variable).to be_falsey
493
- end
494
-
495
- end
496
-
497
- end
@@ -1,8 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Version" do
4
- it "should return ruby-plsql version" do
5
- expect(PLSQL::VERSION).to eq(File.read(File.dirname(__FILE__) + "/../../VERSION").chomp)
6
- end
7
-
8
- end