ruby-plsql 0.5.3 → 0.6.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.
- checksums.yaml +4 -4
- data/.travis.yml +35 -0
- data/.travis/oracle/LICENSE +5 -0
- data/.travis/oracle/README.md +64 -0
- data/.travis/oracle/download.js +100 -0
- data/.travis/oracle/download.sh +16 -0
- data/.travis/oracle/install.sh +32 -0
- data/.travis/setup_accounts.sh +9 -0
- data/Gemfile +4 -3
- data/History.txt +22 -0
- data/README.md +20 -1
- data/VERSION +1 -1
- data/Vagrantfile +2 -2
- data/lib/plsql/connection.rb +2 -3
- data/lib/plsql/jdbc_connection.rb +6 -7
- data/lib/plsql/oci_connection.rb +11 -8
- data/lib/plsql/package.rb +60 -42
- data/lib/plsql/procedure.rb +8 -5
- data/lib/plsql/procedure_call.rb +52 -9
- data/lib/plsql/schema.rb +1 -1
- data/lib/plsql/variable.rb +5 -4
- data/ruby-plsql.gemspec +24 -11
- data/spec/plsql/connection_spec.rb +9 -3
- data/spec/plsql/package_spec.rb +50 -1
- data/spec/plsql/procedure_spec.rb +320 -61
- data/spec/plsql/schema_spec.rb +21 -4
- data/spec/plsql/sql_statements_spec.rb +1 -1
- data/spec/plsql/table_spec.rb +2 -2
- data/spec/plsql/type_spec.rb +1 -1
- data/spec/plsql/variable_spec.rb +37 -45
- data/spec/spec_helper.rb +0 -5
- data/spec/support/create_arunit_user.sql +2 -0
- data/spec/support/custom_config.rb.sample +14 -0
- data/spec/support/unlock_and_setup_hr_user.sql +2 -0
- metadata +31 -7
data/lib/plsql/oci_connection.rb
CHANGED
@@ -68,14 +68,17 @@ module PLSQL
|
|
68
68
|
class Cursor #:nodoc:
|
69
69
|
include Connection::CursorCommon
|
70
70
|
|
71
|
-
# stack of open cursors
|
72
|
-
@@open_cursors = []
|
73
71
|
attr_reader :raw_cursor
|
74
72
|
|
73
|
+
# stack of open cursors per thread
|
74
|
+
def self.open_cursors
|
75
|
+
Thread.current[:plsql_oci_cursor_stack] ||= []
|
76
|
+
end
|
77
|
+
|
75
78
|
def initialize(conn, raw_cursor)
|
76
79
|
@connection = conn
|
77
80
|
@raw_cursor = raw_cursor
|
78
|
-
|
81
|
+
self.class.open_cursors.push self
|
79
82
|
end
|
80
83
|
|
81
84
|
def self.new_from_parse(conn, sql)
|
@@ -125,7 +128,7 @@ module PLSQL
|
|
125
128
|
|
126
129
|
def close
|
127
130
|
# close all cursors that were created after this one
|
128
|
-
while (open_cursor =
|
131
|
+
while (open_cursor = self.class.open_cursors.pop) && !open_cursor.equal?(self)
|
129
132
|
open_cursor.close_raw_cursor
|
130
133
|
end
|
131
134
|
close_raw_cursor
|
@@ -144,19 +147,19 @@ module PLSQL
|
|
144
147
|
def plsql_to_ruby_data_type(metadata)
|
145
148
|
data_type, data_length = metadata[:data_type], metadata[:data_length]
|
146
149
|
case data_type
|
147
|
-
when "VARCHAR2", "CHAR", "NVARCHAR2", "NCHAR"
|
150
|
+
when "VARCHAR", "VARCHAR2", "CHAR", "NVARCHAR2", "NCHAR"
|
148
151
|
[String, data_length || 32767]
|
149
152
|
when "CLOB", "NCLOB"
|
150
153
|
[OCI8::CLOB, nil]
|
151
154
|
when "BLOB"
|
152
155
|
[OCI8::BLOB, nil]
|
153
|
-
when "NUMBER", "PLS_INTEGER", "BINARY_INTEGER"
|
156
|
+
when "NUMBER", "NATURAL", "NATURALN", "POSITIVE", "POSITIVEN", "SIGNTYPE", "SIMPLE_INTEGER", "PLS_INTEGER", "BINARY_INTEGER"
|
154
157
|
[OraNumber, nil]
|
155
158
|
when "DATE"
|
156
159
|
[DateTime, nil]
|
157
160
|
when "TIMESTAMP", "TIMESTAMP WITH TIME ZONE", "TIMESTAMP WITH LOCAL TIME ZONE"
|
158
161
|
[Time, nil]
|
159
|
-
when "TABLE", "VARRAY", "OBJECT"
|
162
|
+
when "TABLE", "VARRAY", "OBJECT", "XMLTYPE"
|
160
163
|
# create Ruby class for collection
|
161
164
|
klass = OCI8::Object::Base.get_class_by_typename(metadata[:sql_type_name])
|
162
165
|
unless klass
|
@@ -336,4 +339,4 @@ module PLSQL
|
|
336
339
|
|
337
340
|
end
|
338
341
|
|
339
|
-
end
|
342
|
+
end
|
data/lib/plsql/package.rb
CHANGED
@@ -2,28 +2,34 @@ module PLSQL
|
|
2
2
|
|
3
3
|
module PackageClassMethods #:nodoc:
|
4
4
|
def find(schema, package)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
5
|
+
package_name = package.to_s.upcase
|
6
|
+
find_in_schema(schema, package_name) || find_by_synonym(schema, package_name)
|
7
|
+
end
|
8
|
+
|
9
|
+
def find_in_schema(schema, package_name)
|
10
|
+
row = schema.select_first(<<-SQL, schema.schema_name, package_name)
|
11
|
+
SELECT object_name
|
12
|
+
FROM all_objects
|
13
|
+
WHERE owner = :owner
|
14
|
+
AND object_name = :package
|
15
|
+
AND object_type = 'PACKAGE'
|
16
|
+
SQL
|
17
|
+
new(schema, package_name) if row
|
18
|
+
end
|
19
|
+
|
20
|
+
def find_by_synonym(schema, package_name)
|
21
|
+
row = schema.select_first(<<-SQL, schema.schema_name, package_name)
|
22
|
+
SELECT o.object_name, o.owner
|
23
|
+
FROM all_synonyms s,
|
24
|
+
all_objects o
|
25
|
+
WHERE s.owner IN (:owner, 'PUBLIC')
|
26
|
+
AND s.synonym_name = :synonym_name
|
27
|
+
AND o.owner = s.table_owner
|
28
|
+
AND o.object_name = s.table_name
|
29
|
+
AND o.object_type = 'PACKAGE'
|
30
|
+
ORDER BY DECODE(s.owner, 'PUBLIC', 1, 0)
|
31
|
+
SQL
|
32
|
+
new(schema, row[0], row[1]) if row
|
27
33
|
end
|
28
34
|
end
|
29
35
|
|
@@ -41,29 +47,41 @@ module PLSQL
|
|
41
47
|
PLSQL::Procedure.find(@schema, name, @package) ? true : false
|
42
48
|
end
|
43
49
|
|
50
|
+
def [](object_name)
|
51
|
+
object_name = object_name.to_s.downcase
|
52
|
+
@package_objects[object_name] ||= [Procedure, Variable].inject(nil) do |res, object_type|
|
53
|
+
res || object_type.find(@schema, object_name, @package, @override_schema_name)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
44
57
|
private
|
45
|
-
|
58
|
+
|
46
59
|
def method_missing(method, *args, &block)
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
object =
|
51
|
-
Procedure
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
60
|
+
method = method.to_s
|
61
|
+
method.chop! if (assignment = method[/=$/])
|
62
|
+
|
63
|
+
case (object = self[method])
|
64
|
+
when Procedure
|
65
|
+
if assignment
|
66
|
+
raise ArgumentError, "Cannot assign value to package procedure '#{method.upcase}'"
|
67
|
+
end
|
68
|
+
object.exec(*args, &block)
|
69
|
+
when Variable
|
70
|
+
if assignment
|
71
|
+
unless args.size == 1 && block.nil?
|
72
|
+
raise ArgumentError, "Just one value can be assigned " \
|
73
|
+
"to package variable '#{method.upcase}'"
|
74
|
+
end
|
75
|
+
object.value = args[0]
|
76
|
+
else
|
77
|
+
unless args.size == 0 && block.nil?
|
78
|
+
raise ArgumentError, "Cannot pass arguments when getting " \
|
79
|
+
"package variable '#{method.upcase}' value"
|
80
|
+
end
|
81
|
+
object.value
|
82
|
+
end
|
61
83
|
else
|
62
|
-
raise ArgumentError, "
|
63
|
-
object.value
|
64
|
-
end
|
65
|
-
else
|
66
|
-
raise ArgumentError, "No PL/SQL procedure or variable '#{method.to_s.upcase}' found"
|
84
|
+
raise ArgumentError, "No PL/SQL procedure or variable '#{method.upcase}' found"
|
67
85
|
end
|
68
86
|
end
|
69
87
|
|
data/lib/plsql/procedure.rb
CHANGED
@@ -64,7 +64,7 @@ module PLSQL
|
|
64
64
|
when 'NUMBER'
|
65
65
|
precision, scale = metadata[:data_precision], metadata[:data_scale]
|
66
66
|
"NUMBER#{precision ? "(#{precision}#{scale ? ",#{scale}": ""})" : ""}"
|
67
|
-
when 'VARCHAR2', 'CHAR'
|
67
|
+
when 'VARCHAR', 'VARCHAR2', 'CHAR'
|
68
68
|
length = case metadata[:char_used]
|
69
69
|
when 'C' then "#{metadata[:char_length]} CHAR"
|
70
70
|
when 'B' then "#{metadata[:data_length]} BYTE"
|
@@ -75,7 +75,7 @@ module PLSQL
|
|
75
75
|
when 'NVARCHAR2', 'NCHAR'
|
76
76
|
length = metadata[:char_length]
|
77
77
|
"#{metadata[:data_type]}#{length && "(#{length})"}"
|
78
|
-
when 'PL/SQL TABLE', 'TABLE', 'VARRAY', 'OBJECT'
|
78
|
+
when 'PL/SQL TABLE', 'TABLE', 'VARRAY', 'OBJECT', 'XMLTYPE'
|
79
79
|
metadata[:sql_type_name]
|
80
80
|
else
|
81
81
|
metadata[:data_type]
|
@@ -100,11 +100,13 @@ module PLSQL
|
|
100
100
|
|
101
101
|
# subprogram_id column is available just from version 10g
|
102
102
|
subprogram_id_column = (@schema.connection.database_version <=> [10, 2, 0, 2]) >= 0 ? 'subprogram_id' : 'NULL'
|
103
|
+
# defaulted is available just from version 11g
|
104
|
+
defaulted_column = (@schema.connection.database_version <=> [11, 0, 0, 0]) >= 0 ? 'defaulted' : 'NULL'
|
103
105
|
|
104
106
|
@schema.select_all(
|
105
107
|
"SELECT #{subprogram_id_column}, object_name, TO_NUMBER(overload), argument_name, position, data_level,
|
106
108
|
data_type, in_out, data_length, data_precision, data_scale, char_used,
|
107
|
-
char_length, type_owner, type_name, type_subname
|
109
|
+
char_length, type_owner, type_name, type_subname, #{defaulted_column}
|
108
110
|
FROM all_arguments
|
109
111
|
WHERE object_id = :object_id
|
110
112
|
AND owner = :owner
|
@@ -115,7 +117,7 @@ module PLSQL
|
|
115
117
|
|
116
118
|
subprogram_id, object_name, overload, argument_name, position, data_level,
|
117
119
|
data_type, in_out, data_length, data_precision, data_scale, char_used,
|
118
|
-
char_length, type_owner, type_name, type_subname = r
|
120
|
+
char_length, type_owner, type_name, type_subname, defaulted = r
|
119
121
|
|
120
122
|
@overloaded ||= !overload.nil?
|
121
123
|
# if not overloaded then store arguments at key 0
|
@@ -155,7 +157,8 @@ module PLSQL
|
|
155
157
|
:type_owner => type_owner,
|
156
158
|
:type_name => type_name,
|
157
159
|
:type_subname => type_subname,
|
158
|
-
:sql_type_name => sql_type_name
|
160
|
+
:sql_type_name => sql_type_name,
|
161
|
+
:defaulted => defaulted
|
159
162
|
}
|
160
163
|
if tmp_table_name
|
161
164
|
@tmp_table_names[overload] << [(argument_metadata[:tmp_table_name] = tmp_table_name), argument_metadata]
|
data/lib/plsql/procedure_call.rb
CHANGED
@@ -109,9 +109,9 @@ module PLSQL
|
|
109
109
|
end
|
110
110
|
|
111
111
|
MATCHING_TYPES = {
|
112
|
-
:integer => ['NUMBER', 'PLS_INTEGER', 'BINARY_INTEGER'],
|
112
|
+
:integer => ['NUMBER', 'NATURAL', 'NATURALN', 'POSITIVE', 'POSITIVEN', 'SIGNTYPE', 'SIMPLE_INTEGER', 'PLS_INTEGER', 'BINARY_INTEGER'],
|
113
113
|
:decimal => ['NUMBER', 'BINARY_FLOAT', 'BINARY_DOUBLE'],
|
114
|
-
:string => ['VARCHAR2', 'NVARCHAR2', 'CHAR', 'NCHAR', 'CLOB', 'BLOB'],
|
114
|
+
:string => ['VARCHAR', 'VARCHAR2', 'NVARCHAR2', 'CHAR', 'NCHAR', 'CLOB', 'BLOB', 'XMLTYPE'],
|
115
115
|
:date => ['DATE'],
|
116
116
|
:time => ['DATE', 'TIMESTAMP', 'TIMESTAMP WITH TIME ZONE', 'TIMESTAMP WITH LOCAL TIME ZONE'],
|
117
117
|
:boolean => ['PL/SQL BOOLEAN'],
|
@@ -236,6 +236,14 @@ module PLSQL
|
|
236
236
|
@bind_values[argument] = value.nil? ? nil : (value ? 1 : 0)
|
237
237
|
@bind_metadata[argument] = argument_metadata.merge(:data_type => "NUMBER", :data_precision => 1)
|
238
238
|
"l_#{argument}"
|
239
|
+
when 'UNDEFINED'
|
240
|
+
if argument_metadata[:type_name] == 'XMLTYPE'
|
241
|
+
@declare_sql << "l_#{argument} XMLTYPE;\n"
|
242
|
+
@assignment_sql << "l_#{argument} := XMLTYPE(:#{argument});\n" if not value.nil?
|
243
|
+
@bind_values[argument] = value if not value.nil?
|
244
|
+
@bind_metadata[argument] = argument_metadata.merge(:data_type => "CLOB")
|
245
|
+
"l_#{argument}"
|
246
|
+
end
|
239
247
|
else
|
240
248
|
# TABLE or PL/SQL TABLE type defined inside package
|
241
249
|
if argument_metadata[:tmp_table_name]
|
@@ -337,9 +345,16 @@ module PLSQL
|
|
337
345
|
metadata = argument_metadata[:fields][field]
|
338
346
|
raise ArgumentError, "Wrong field name #{key.inspect} passed to PL/SQL record argument #{argument.inspect}" unless metadata
|
339
347
|
bind_variable = :"#{argument}_f#{metadata[:position]}"
|
340
|
-
|
341
|
-
|
342
|
-
|
348
|
+
case metadata[:data_type]
|
349
|
+
when 'PL/SQL BOOLEAN'
|
350
|
+
sql << "l_#{argument}.#{field} := (:#{bind_variable} = 1);\n"
|
351
|
+
bind_values[bind_variable] = value.nil? ? nil : (value ? 1 : 0)
|
352
|
+
bind_metadata[bind_variable] = metadata.merge(:data_type => "NUMBER", :data_precision => 1)
|
353
|
+
else
|
354
|
+
sql << "l_#{argument}.#{field} := :#{bind_variable};\n"
|
355
|
+
bind_values[bind_variable] = value
|
356
|
+
bind_metadata[bind_variable] = metadata
|
357
|
+
end
|
343
358
|
end
|
344
359
|
[sql, bind_values, bind_metadata]
|
345
360
|
end
|
@@ -362,11 +377,29 @@ module PLSQL
|
|
362
377
|
# should use different output bind variable as JDBC does not support
|
363
378
|
# if output bind variable appears in several places
|
364
379
|
bind_variable = :"#{argument}_o#{metadata[:position]}"
|
365
|
-
|
366
|
-
|
367
|
-
|
380
|
+
case metadata[:data_type]
|
381
|
+
when 'PL/SQL BOOLEAN'
|
382
|
+
@return_vars << bind_variable
|
383
|
+
@return_vars_metadata[bind_variable] = metadata.merge(:data_type => "NUMBER", :data_precision => 1)
|
384
|
+
arg_field = "l_#{argument}.#{field}"
|
385
|
+
@return_sql << ":#{bind_variable} := " << "CASE WHEN #{arg_field} = true THEN 1 " <<
|
386
|
+
"WHEN #{arg_field} = false THEN 0 ELSE NULL END;\n"
|
387
|
+
else
|
388
|
+
@return_vars << bind_variable
|
389
|
+
@return_vars_metadata[bind_variable] = metadata
|
390
|
+
@return_sql << ":#{bind_variable} := l_#{argument}.#{field};\n"
|
391
|
+
end
|
368
392
|
end
|
369
393
|
"l_#{argument} := " if is_return_value
|
394
|
+
when 'UNDEFINED'
|
395
|
+
if argument_metadata[:type_name] == 'XMLTYPE'
|
396
|
+
@declare_sql << "l_#{argument} XMLTYPE;\n" if is_return_value
|
397
|
+
bind_variable = :"o_#{argument}"
|
398
|
+
@return_vars << bind_variable
|
399
|
+
@return_vars_metadata[bind_variable] = argument_metadata.merge(:data_type => "CLOB")
|
400
|
+
@return_sql << ":#{bind_variable} := CASE WHEN l_#{argument} IS NOT NULL THEN l_#{argument}.getclobval() END;\n"
|
401
|
+
"l_#{argument} := " if is_return_value
|
402
|
+
end
|
370
403
|
when 'PL/SQL BOOLEAN'
|
371
404
|
@declare_sql << "l_#{argument} BOOLEAN;\n" if is_return_value
|
372
405
|
@declare_sql << "o_#{argument} NUMBER(1);\n"
|
@@ -468,12 +501,22 @@ module PLSQL
|
|
468
501
|
when 'PL/SQL RECORD'
|
469
502
|
return_value = {}
|
470
503
|
argument_metadata[:fields].each do |field, metadata|
|
471
|
-
|
504
|
+
field_value = @cursor[":#{argument}_o#{metadata[:position]}"]
|
505
|
+
case metadata[:data_type]
|
506
|
+
when 'PL/SQL BOOLEAN'
|
507
|
+
return_value[field] = field_value.nil? ? nil : field_value == 1
|
508
|
+
else
|
509
|
+
return_value[field] = field_value
|
510
|
+
end
|
472
511
|
end
|
473
512
|
return_value
|
474
513
|
when 'PL/SQL BOOLEAN'
|
475
514
|
numeric_value = @cursor[":o_#{argument}"]
|
476
515
|
numeric_value.nil? ? nil : numeric_value == 1
|
516
|
+
when 'UNDEFINED'
|
517
|
+
if argument_metadata[:type_name] == 'XMLTYPE'
|
518
|
+
@cursor[":o_#{argument}"]
|
519
|
+
end
|
477
520
|
else
|
478
521
|
if argument_metadata[:tmp_table_name]
|
479
522
|
is_index_by_table = argument_metadata[:data_type] == 'PL/SQL TABLE'
|
data/lib/plsql/schema.rb
CHANGED
@@ -90,7 +90,7 @@ module PLSQL
|
|
90
90
|
# Current Oracle schema name
|
91
91
|
def schema_name
|
92
92
|
return nil unless connection
|
93
|
-
@schema_name ||= select_first("SELECT SYS_CONTEXT('userenv','
|
93
|
+
@schema_name ||= select_first("SELECT SYS_CONTEXT('userenv','current_schema') FROM dual")[0]
|
94
94
|
end
|
95
95
|
|
96
96
|
# Default timezone to which database values will be converted - :utc or :local
|
data/lib/plsql/variable.rb
CHANGED
@@ -47,11 +47,12 @@ module PLSQL
|
|
47
47
|
|
48
48
|
def metadata(type_string)
|
49
49
|
case type_string
|
50
|
-
when /^(VARCHAR2|CHAR|NVARCHAR2|NCHAR)(\((\d+)[\s\w]*\))?$/
|
50
|
+
when /^(VARCHAR|VARCHAR2|CHAR|NVARCHAR2|NCHAR)(\((\d+)[\s\w]*\))?$/
|
51
51
|
{:data_type => $1, :data_length => $3.to_i, :in_out => 'IN/OUT'}
|
52
52
|
when /^(CLOB|NCLOB|BLOB)$/,
|
53
|
-
/^(NUMBER)(\(.*\))?$/, /^(PLS_INTEGER|BINARY_INTEGER)$/,
|
54
|
-
/^(DATE|TIMESTAMP|TIMESTAMP WITH TIME ZONE|TIMESTAMP WITH LOCAL TIME ZONE)
|
53
|
+
/^(NUMBER)(\(.*\))?$/, /^(NATURAL|NATURALN|POSITIVE|POSITIVEN|SIGNTYPE|SIMPLE_INTEGER|PLS_INTEGER|BINARY_INTEGER)$/,
|
54
|
+
/^(DATE|TIMESTAMP|TIMESTAMP WITH TIME ZONE|TIMESTAMP WITH LOCAL TIME ZONE)$/,
|
55
|
+
/^(XMLTYPE)$/
|
55
56
|
{:data_type => $1, :in_out => 'IN/OUT'}
|
56
57
|
when /^INTEGER$/
|
57
58
|
{:data_type => 'NUMBER', :in_out => 'IN/OUT'}
|
@@ -143,4 +144,4 @@ module PLSQL
|
|
143
144
|
|
144
145
|
end
|
145
146
|
|
146
|
-
end
|
147
|
+
end
|
data/ruby-plsql.gemspec
CHANGED
@@ -2,22 +2,29 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: ruby-plsql 0.
|
5
|
+
# stub: ruby-plsql 0.6.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "ruby-plsql"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.6.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Raimonds Simanovskis"]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2016-03-13"
|
15
15
|
s.description = "ruby-plsql gem provides simple Ruby API for calling Oracle PL/SQL procedures.\nIt could be used both for accessing Oracle PL/SQL API procedures in legacy applications\nas well as it could be used to create PL/SQL unit tests using Ruby testing libraries.\n"
|
16
16
|
s.email = "raimonds.simanovskis@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"README.md"
|
19
19
|
]
|
20
20
|
s.files = [
|
21
|
+
".travis.yml",
|
22
|
+
".travis/oracle/LICENSE",
|
23
|
+
".travis/oracle/README.md",
|
24
|
+
".travis/oracle/download.js",
|
25
|
+
".travis/oracle/download.sh",
|
26
|
+
".travis/oracle/install.sh",
|
27
|
+
".travis/setup_accounts.sh",
|
21
28
|
"Gemfile",
|
22
29
|
"History.txt",
|
23
30
|
"License.txt",
|
@@ -57,11 +64,14 @@ Gem::Specification.new do |s|
|
|
57
64
|
"spec/plsql/view_spec.rb",
|
58
65
|
"spec/spec.opts",
|
59
66
|
"spec/spec_helper.rb",
|
67
|
+
"spec/support/create_arunit_user.sql",
|
68
|
+
"spec/support/custom_config.rb.sample",
|
60
69
|
"spec/support/file_check_script.sh",
|
61
|
-
"spec/support/test_db.rb"
|
70
|
+
"spec/support/test_db.rb",
|
71
|
+
"spec/support/unlock_and_setup_hr_user.sql"
|
62
72
|
]
|
63
73
|
s.homepage = "http://github.com/rsim/ruby-plsql"
|
64
|
-
s.rubygems_version = "2.
|
74
|
+
s.rubygems_version = "2.5.1"
|
65
75
|
s.summary = "Ruby API for calling Oracle PL/SQL procedures."
|
66
76
|
|
67
77
|
if s.respond_to? :specification_version then
|
@@ -70,25 +80,28 @@ Gem::Specification.new do |s|
|
|
70
80
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
71
81
|
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
72
82
|
s.add_development_dependency(%q<rspec>, ["~> 3.1"])
|
83
|
+
s.add_development_dependency(%q<rspec_junit_formatter>, [">= 0"])
|
73
84
|
s.add_development_dependency(%q<activerecord>, ["< 4.3.0", ">= 3.2.3"])
|
74
|
-
s.add_development_dependency(%q<activerecord-oracle_enhanced-adapter>, ["< 1.
|
85
|
+
s.add_development_dependency(%q<activerecord-oracle_enhanced-adapter>, ["< 1.7.0", ">= 1.4.1"])
|
75
86
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
76
|
-
s.add_development_dependency(%q<ruby-oci8>, ["~> 2.1
|
87
|
+
s.add_development_dependency(%q<ruby-oci8>, ["~> 2.1"])
|
77
88
|
else
|
78
89
|
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
79
90
|
s.add_dependency(%q<rspec>, ["~> 3.1"])
|
91
|
+
s.add_dependency(%q<rspec_junit_formatter>, [">= 0"])
|
80
92
|
s.add_dependency(%q<activerecord>, ["< 4.3.0", ">= 3.2.3"])
|
81
|
-
s.add_dependency(%q<activerecord-oracle_enhanced-adapter>, ["< 1.
|
93
|
+
s.add_dependency(%q<activerecord-oracle_enhanced-adapter>, ["< 1.7.0", ">= 1.4.1"])
|
82
94
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
83
|
-
s.add_dependency(%q<ruby-oci8>, ["~> 2.1
|
95
|
+
s.add_dependency(%q<ruby-oci8>, ["~> 2.1"])
|
84
96
|
end
|
85
97
|
else
|
86
98
|
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
87
99
|
s.add_dependency(%q<rspec>, ["~> 3.1"])
|
100
|
+
s.add_dependency(%q<rspec_junit_formatter>, [">= 0"])
|
88
101
|
s.add_dependency(%q<activerecord>, ["< 4.3.0", ">= 3.2.3"])
|
89
|
-
s.add_dependency(%q<activerecord-oracle_enhanced-adapter>, ["< 1.
|
102
|
+
s.add_dependency(%q<activerecord-oracle_enhanced-adapter>, ["< 1.7.0", ">= 1.4.1"])
|
90
103
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
91
|
-
s.add_dependency(%q<ruby-oci8>, ["~> 2.1
|
104
|
+
s.add_dependency(%q<ruby-oci8>, ["~> 2.1"])
|
92
105
|
end
|
93
106
|
end
|
94
107
|
|
@@ -7,7 +7,6 @@ describe "Connection" do
|
|
7
7
|
before(:all) do
|
8
8
|
@raw_conn = get_connection
|
9
9
|
@conn = PLSQL::Connection.create( @raw_conn )
|
10
|
-
@conn.set_time_zone
|
11
10
|
end
|
12
11
|
|
13
12
|
after(:all) do
|
@@ -25,7 +24,6 @@ describe "Connection" do
|
|
25
24
|
|
26
25
|
before(:each) do
|
27
26
|
@conn1 = PLSQL::Connection.create( @raw_conn1 )
|
28
|
-
@conn1.set_time_zone
|
29
27
|
end
|
30
28
|
|
31
29
|
it "should create connection" do
|
@@ -53,6 +51,11 @@ describe "Connection" do
|
|
53
51
|
# Ruby 1.8 and 1.9
|
54
52
|
unless defined?(JRuby)
|
55
53
|
describe "OCI data type conversions" do
|
54
|
+
it "should translate PL/SQL VARCHAR to Ruby String" do
|
55
|
+
expect(@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR", :data_length => 100)).to eq [String, 100]
|
56
|
+
expect(@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR", :data_length => nil)).to eq [String, 32767]
|
57
|
+
end
|
58
|
+
|
56
59
|
it "should translate PL/SQL VARCHAR2 to Ruby String" do
|
57
60
|
expect(@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR2", :data_length => 100)).to eq [String, 100]
|
58
61
|
expect(@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR2", :data_length => nil)).to eq [String, 32767]
|
@@ -124,6 +127,10 @@ describe "Connection" do
|
|
124
127
|
else
|
125
128
|
|
126
129
|
describe "JDBC data type conversions" do
|
130
|
+
it "should translate PL/SQL VARCHAR to Ruby String" do
|
131
|
+
expect(@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR", :data_length => 100)).to eq [String, 100]
|
132
|
+
expect(@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR", :data_length => nil)).to eq [String, 32767]
|
133
|
+
end
|
127
134
|
it "should translate PL/SQL VARCHAR2 to Ruby String" do
|
128
135
|
expect(@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR2", :data_length => 100)).to eq [String, 100]
|
129
136
|
expect(@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR2", :data_length => nil)).to eq [String, 32767]
|
@@ -468,7 +475,6 @@ describe "Connection" do
|
|
468
475
|
def reconnect_connection
|
469
476
|
@raw_conn = get_connection
|
470
477
|
@conn = PLSQL::Connection.create( @raw_conn )
|
471
|
-
@conn.set_time_zone
|
472
478
|
end
|
473
479
|
|
474
480
|
it "should drop current session ruby temporary tables" do
|