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.
- checksums.yaml +4 -4
- data/History.txt +2 -0
- data/VERSION +1 -1
- data/lib/plsql/connection.rb +14 -14
- data/lib/plsql/helpers.rb +3 -3
- data/lib/plsql/jdbc_connection.rb +3 -3
- data/lib/plsql/oci_connection.rb +8 -4
- data/lib/plsql/package.rb +3 -3
- data/lib/plsql/procedure.rb +32 -17
- data/lib/plsql/procedure_call.rb +15 -15
- data/lib/plsql/schema.rb +13 -9
- data/lib/plsql/sequence.rb +2 -2
- data/lib/plsql/table.rb +6 -6
- data/lib/plsql/type.rb +7 -7
- data/lib/plsql/variable.rb +4 -4
- data/lib/plsql/version.rb +1 -1
- data/lib/plsql/view.rb +2 -2
- metadata +13 -138
- data/.github/stale.yml +0 -37
- data/.github/workflows/rubocop.yml +0 -37
- data/.github/workflows/test.yml +0 -69
- data/.rubocop.yml +0 -147
- data/.travis/oracle/download.sh +0 -15
- data/.travis/oracle/install.sh +0 -32
- data/.travis/setup_accounts.sh +0 -9
- data/.travis.yml +0 -88
- data/Gemfile +0 -24
- data/Rakefile +0 -53
- data/Vagrantfile +0 -38
- data/ci/network/admin/tnsnames.ora +0 -7
- data/ci/setup_accounts.sh +0 -9
- data/gemfiles/Gemfile.activerecord-5.0 +0 -21
- data/gemfiles/Gemfile.activerecord-5.1 +0 -21
- data/gemfiles/Gemfile.activerecord-5.2 +0 -21
- data/gemfiles/Gemfile.activerecord-6.0 +0 -21
- data/gemfiles/Gemfile.activerecord-6.1 +0 -21
- data/gemfiles/Gemfile.activerecord-main +0 -21
- data/ruby-plsql.gemspec +0 -114
- data/spec/plsql/connection_spec.rb +0 -505
- data/spec/plsql/package_spec.rb +0 -172
- data/spec/plsql/procedure_spec.rb +0 -2390
- data/spec/plsql/schema_spec.rb +0 -364
- data/spec/plsql/sequence_spec.rb +0 -67
- data/spec/plsql/sql_statements_spec.rb +0 -91
- data/spec/plsql/table_spec.rb +0 -376
- data/spec/plsql/type_spec.rb +0 -299
- data/spec/plsql/variable_spec.rb +0 -497
- data/spec/plsql/version_spec.rb +0 -8
- data/spec/plsql/view_spec.rb +0 -264
- data/spec/spec.opts +0 -6
- data/spec/spec_helper.rb +0 -121
- data/spec/support/create_arunit_user.sql +0 -2
- data/spec/support/custom_config.rb.sample +0 -14
- data/spec/support/file_check_script.sh +0 -9
- data/spec/support/test_db.rb +0 -149
- data/spec/support/unlock_and_setup_hr_user.sql +0 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e240a454b5016fb465baaff47830601ea5f06f9a0f4ed7f2e032e2e8027c8841
|
|
4
|
+
data.tar.gz: 8209b0f8b037838e7be37578a396b8652855540abd6a0c2cbf226adfaf7a598e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: af3ba3c7a782369e6e4f94afe467194f155fc961dc80e946ebbbaec07f48244169d33f1c0c387d6710752b7590f70c9cc5fb84bc21f8687b8c520d32ed09f557
|
|
7
|
+
data.tar.gz: 2fe1c1fa55a48cc547a3f34f371aba37147c4d3c8efc2c34d104b42b8e250251f6d233d65c6fedba42855774ccf559d6aed4164f341823b5c6fbbbb605acb047
|
data/History.txt
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.9.0
|
data/lib/plsql/connection.rb
CHANGED
|
@@ -3,13 +3,13 @@ module PLSQL
|
|
|
3
3
|
attr_reader :raw_driver
|
|
4
4
|
attr_reader :activerecord_class
|
|
5
5
|
|
|
6
|
-
def initialize(raw_conn, ar_class = nil)
|
|
6
|
+
def initialize(raw_conn, ar_class = nil) # :nodoc:
|
|
7
7
|
@raw_driver = self.class.driver_type
|
|
8
8
|
@raw_connection = raw_conn
|
|
9
9
|
@activerecord_class = ar_class
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
def self.create(raw_conn, ar_class = nil)
|
|
12
|
+
def self.create(raw_conn, ar_class = nil) # :nodoc:
|
|
13
13
|
if ar_class && !(defined?(::ActiveRecord) && ar_class.ancestors.include?(::ActiveRecord::Base))
|
|
14
14
|
raise ArgumentError, "Wrong ActiveRecord class"
|
|
15
15
|
end
|
|
@@ -23,7 +23,7 @@ module PLSQL
|
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
def self.create_new(params)
|
|
26
|
+
def self.create_new(params) # :nodoc:
|
|
27
27
|
conn = case driver_type
|
|
28
28
|
when :oci
|
|
29
29
|
OCIConnection.create_raw(params)
|
|
@@ -36,7 +36,7 @@ module PLSQL
|
|
|
36
36
|
conn
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
def self.driver_type
|
|
39
|
+
def self.driver_type # :nodoc:
|
|
40
40
|
# MRI 1.8.6 or YARV 1.9.1 or TruffleRuby
|
|
41
41
|
@driver_type ||= if (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby" || RUBY_ENGINE == "truffleruby") && defined?(OCI8)
|
|
42
42
|
:oci
|
|
@@ -67,18 +67,18 @@ module PLSQL
|
|
|
67
67
|
@raw_driver == :jdbc
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
def logoff
|
|
70
|
+
def logoff # :nodoc:
|
|
71
71
|
# Rollback any uncommited transactions
|
|
72
72
|
rollback
|
|
73
73
|
# Common cleanup activities before logoff, should be called from particular driver method
|
|
74
74
|
drop_session_ruby_temporary_tables
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
-
def commit
|
|
77
|
+
def commit # :nodoc:
|
|
78
78
|
raise NoMethodError, "Not implemented for this raw driver"
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
-
def rollback
|
|
81
|
+
def rollback # :nodoc:
|
|
82
82
|
raise NoMethodError, "Not implemented for this raw driver"
|
|
83
83
|
end
|
|
84
84
|
|
|
@@ -98,21 +98,21 @@ module PLSQL
|
|
|
98
98
|
raise NoMethodError, "Not implemented for this raw driver"
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
def select_first(sql, *bindvars)
|
|
101
|
+
def select_first(sql, *bindvars) # :nodoc:
|
|
102
102
|
cursor = cursor_from_query(sql, bindvars, prefetch_rows: 1)
|
|
103
103
|
cursor.fetch
|
|
104
104
|
ensure
|
|
105
105
|
cursor.close rescue nil
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
-
def select_hash_first(sql, *bindvars)
|
|
108
|
+
def select_hash_first(sql, *bindvars) # :nodoc:
|
|
109
109
|
cursor = cursor_from_query(sql, bindvars, prefetch_rows: 1)
|
|
110
110
|
cursor.fetch_hash
|
|
111
111
|
ensure
|
|
112
112
|
cursor.close rescue nil
|
|
113
113
|
end
|
|
114
114
|
|
|
115
|
-
def select_all(sql, *bindvars, &block)
|
|
115
|
+
def select_all(sql, *bindvars, &block) # :nodoc:
|
|
116
116
|
cursor = cursor_from_query(sql, bindvars)
|
|
117
117
|
results = []
|
|
118
118
|
row_count = 0
|
|
@@ -129,7 +129,7 @@ module PLSQL
|
|
|
129
129
|
cursor.close rescue nil
|
|
130
130
|
end
|
|
131
131
|
|
|
132
|
-
def select_hash_all(sql, *bindvars, &block)
|
|
132
|
+
def select_hash_all(sql, *bindvars, &block) # :nodoc:
|
|
133
133
|
cursor = cursor_from_query(sql, bindvars)
|
|
134
134
|
results = []
|
|
135
135
|
row_count = 0
|
|
@@ -146,11 +146,11 @@ module PLSQL
|
|
|
146
146
|
cursor.close rescue nil
|
|
147
147
|
end
|
|
148
148
|
|
|
149
|
-
def exec(sql, *bindvars)
|
|
149
|
+
def exec(sql, *bindvars) # :nodoc:
|
|
150
150
|
raise NoMethodError, "Not implemented for this raw driver"
|
|
151
151
|
end
|
|
152
152
|
|
|
153
|
-
def parse(sql)
|
|
153
|
+
def parse(sql) # :nodoc:
|
|
154
154
|
raise NoMethodError, "Not implemented for this raw driver"
|
|
155
155
|
end
|
|
156
156
|
|
|
@@ -181,7 +181,7 @@ module PLSQL
|
|
|
181
181
|
|
|
182
182
|
# all_synonyms view is quite slow therefore
|
|
183
183
|
# this implementation is overriden in OCI connection with faster native OCI method
|
|
184
|
-
def describe_synonym(schema_name, synonym_name)
|
|
184
|
+
def describe_synonym(schema_name, synonym_name) # :nodoc:
|
|
185
185
|
select_first(
|
|
186
186
|
"SELECT table_owner, table_name FROM all_synonyms WHERE owner = :owner AND synonym_name = :synonym_name",
|
|
187
187
|
schema_name.to_s.upcase, synonym_name.to_s.upcase)
|
data/lib/plsql/helpers.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
module PLSQL
|
|
2
|
-
module ArrayHelpers
|
|
3
|
-
def self.to_hash(keys, values)
|
|
1
|
+
module PLSQL # :nodoc:
|
|
2
|
+
module ArrayHelpers # :nodoc:
|
|
3
|
+
def self.to_hash(keys, values) # :nodoc:
|
|
4
4
|
(0...keys.size).inject({}) { |hash, i| hash[keys[i]] = values[i]; hash }
|
|
5
5
|
end
|
|
6
6
|
end
|
|
@@ -46,7 +46,7 @@ rescue LoadError, NameError
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
module PLSQL
|
|
49
|
-
class JDBCConnection < Connection
|
|
49
|
+
class JDBCConnection < Connection # :nodoc:
|
|
50
50
|
def self.create_raw(params)
|
|
51
51
|
database = params[:database]
|
|
52
52
|
url = if ENV["TNS_ADMIN"] && database && !params[:host] && !params[:url]
|
|
@@ -98,7 +98,7 @@ module PLSQL
|
|
|
98
98
|
cs.close rescue nil
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
class CallableStatement
|
|
101
|
+
class CallableStatement # :nodoc:
|
|
102
102
|
def initialize(conn, sql)
|
|
103
103
|
@sql = sql
|
|
104
104
|
@connection = conn
|
|
@@ -145,7 +145,7 @@ module PLSQL
|
|
|
145
145
|
end
|
|
146
146
|
end
|
|
147
147
|
|
|
148
|
-
class Cursor
|
|
148
|
+
class Cursor # :nodoc:
|
|
149
149
|
include Connection::CursorCommon
|
|
150
150
|
|
|
151
151
|
attr_reader :result_set
|
data/lib/plsql/oci_connection.rb
CHANGED
|
@@ -24,7 +24,7 @@ if (oci8_version_ints <=> required_oci8_version) < 0
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
module PLSQL
|
|
27
|
-
class OCIConnection < Connection
|
|
27
|
+
class OCIConnection < Connection # :nodoc:
|
|
28
28
|
def self.create_raw(params)
|
|
29
29
|
connection_string = if params[:host]
|
|
30
30
|
"//#{params[:host]}:#{params[:port] || 1521}/#{params[:database]}"
|
|
@@ -64,7 +64,7 @@ module PLSQL
|
|
|
64
64
|
true
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
class Cursor
|
|
67
|
+
class Cursor # :nodoc:
|
|
68
68
|
include Connection::CursorCommon
|
|
69
69
|
|
|
70
70
|
attr_reader :raw_cursor
|
|
@@ -157,7 +157,7 @@ module PLSQL
|
|
|
157
157
|
[DateTime, nil]
|
|
158
158
|
when "TIMESTAMP", "TIMESTAMP WITH TIME ZONE", "TIMESTAMP WITH LOCAL TIME ZONE"
|
|
159
159
|
[Time, nil]
|
|
160
|
-
when "TABLE", "VARRAY", "OBJECT", "XMLTYPE"
|
|
160
|
+
when "TABLE", "VARRAY", "OBJECT", "XMLTYPE", "OPAQUE/XMLTYPE"
|
|
161
161
|
# create Ruby class for collection
|
|
162
162
|
klass = OCI8::Object::Base.get_class_by_typename(metadata[:sql_type_name])
|
|
163
163
|
unless klass
|
|
@@ -289,7 +289,11 @@ module PLSQL
|
|
|
289
289
|
# ActiveRecord Oracle enhanced adapter puts OCI8EnhancedAutoRecover wrapper around OCI8
|
|
290
290
|
# in this case we need to pass original OCI8 connection
|
|
291
291
|
else
|
|
292
|
-
raw_connection.
|
|
292
|
+
if raw_connection.instance_variable_defined?(:@raw_connection)
|
|
293
|
+
raw_connection.instance_variable_get(:@raw_connection)
|
|
294
|
+
else
|
|
295
|
+
raw_connection.instance_variable_get(:@connection)
|
|
296
|
+
end
|
|
293
297
|
end
|
|
294
298
|
end
|
|
295
299
|
|
data/lib/plsql/package.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module PLSQL
|
|
2
|
-
module PackageClassMethods
|
|
2
|
+
module PackageClassMethods # :nodoc:
|
|
3
3
|
def find(schema, package)
|
|
4
4
|
package_name = package.to_s.upcase
|
|
5
5
|
find_in_schema(schema, package_name) || find_by_synonym(schema, package_name)
|
|
@@ -32,7 +32,7 @@ module PLSQL
|
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
class Package
|
|
35
|
+
class Package # :nodoc:
|
|
36
36
|
extend PackageClassMethods
|
|
37
37
|
|
|
38
38
|
def initialize(schema, package, override_schema_name = nil)
|
|
@@ -56,7 +56,7 @@ module PLSQL
|
|
|
56
56
|
private
|
|
57
57
|
|
|
58
58
|
def method_missing(method, *args, &block)
|
|
59
|
-
method = method.to_s
|
|
59
|
+
method = +method.to_s
|
|
60
60
|
method.chop! if (assignment = method[/=$/])
|
|
61
61
|
|
|
62
62
|
case (object = self[method])
|
data/lib/plsql/procedure.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module PLSQL
|
|
2
|
-
module ProcedureClassMethods
|
|
2
|
+
module ProcedureClassMethods # :nodoc:
|
|
3
3
|
def find(schema, procedure, package = nil, override_schema_name = nil)
|
|
4
4
|
if package.nil?
|
|
5
5
|
if (row = schema.select_first(
|
|
@@ -53,12 +53,12 @@ module PLSQL
|
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
module ProcedureCommon
|
|
56
|
+
module ProcedureCommon # :nodoc:
|
|
57
57
|
attr_reader :arguments, :argument_list, :out_list, :return
|
|
58
58
|
attr_reader :schema, :schema_name, :package, :procedure
|
|
59
59
|
|
|
60
60
|
# return type string from metadata that can be used in DECLARE block or table definition
|
|
61
|
-
def self.type_to_sql(metadata)
|
|
61
|
+
def self.type_to_sql(metadata) # :nodoc:
|
|
62
62
|
case metadata[:data_type]
|
|
63
63
|
when "NUMBER"
|
|
64
64
|
precision, scale = metadata[:data_precision], metadata[:data_scale]
|
|
@@ -82,7 +82,7 @@ module PLSQL
|
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
# get procedure argument metadata from data dictionary
|
|
85
|
-
def get_argument_metadata
|
|
85
|
+
def get_argument_metadata # :nodoc:
|
|
86
86
|
if (@schema.connection.database_version <=> [18, 0, 0, 0]) >= 0
|
|
87
87
|
get_argument_metadata_from_18c
|
|
88
88
|
else
|
|
@@ -90,7 +90,7 @@ module PLSQL
|
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
-
def get_argument_metadata_below_18c
|
|
93
|
+
def get_argument_metadata_below_18c # :nodoc:
|
|
94
94
|
@arguments = {}
|
|
95
95
|
@argument_list = {}
|
|
96
96
|
@out_list = {}
|
|
@@ -126,6 +126,9 @@ module PLSQL
|
|
|
126
126
|
data_type, in_out, data_length, data_precision, data_scale, char_used,
|
|
127
127
|
char_length, type_owner, type_name, type_subname, defaulted = r
|
|
128
128
|
|
|
129
|
+
# Oracle 23c reports BOOLEAN as "BOOLEAN" instead of "PL/SQL BOOLEAN"
|
|
130
|
+
data_type = "PL/SQL BOOLEAN" if data_type == "BOOLEAN"
|
|
131
|
+
|
|
129
132
|
@overloaded ||= !overload.nil?
|
|
130
133
|
# if not overloaded then store arguments at key 0
|
|
131
134
|
overload ||= 0
|
|
@@ -206,7 +209,7 @@ module PLSQL
|
|
|
206
209
|
end
|
|
207
210
|
|
|
208
211
|
# get procedure argument metadata from data dictionary
|
|
209
|
-
def get_argument_metadata_from_18c
|
|
212
|
+
def get_argument_metadata_from_18c # :nodoc:
|
|
210
213
|
@arguments = {}
|
|
211
214
|
@argument_list = {}
|
|
212
215
|
@out_list = {}
|
|
@@ -231,10 +234,13 @@ module PLSQL
|
|
|
231
234
|
@object_id, @schema_name, @procedure
|
|
232
235
|
) do |r|
|
|
233
236
|
|
|
234
|
-
subprogram_id,
|
|
237
|
+
subprogram_id, _object_name, overload, argument_name, position,
|
|
235
238
|
data_type, in_out, data_length, data_precision, data_scale, char_used,
|
|
236
239
|
char_length, type_owner, type_name, type_package, type_object_type, defaulted = r
|
|
237
240
|
|
|
241
|
+
# Oracle 23c reports BOOLEAN as "BOOLEAN" instead of "PL/SQL BOOLEAN"
|
|
242
|
+
data_type = "PL/SQL BOOLEAN" if data_type == "BOOLEAN"
|
|
243
|
+
|
|
238
244
|
@overloaded ||= !overload.nil?
|
|
239
245
|
# if not overloaded then store arguments at key 0
|
|
240
246
|
overload ||= 0
|
|
@@ -298,7 +304,7 @@ module PLSQL
|
|
|
298
304
|
construct_argument_list_for_overloads
|
|
299
305
|
end
|
|
300
306
|
|
|
301
|
-
def construct_argument_list_for_overloads
|
|
307
|
+
def construct_argument_list_for_overloads # :nodoc:
|
|
302
308
|
@overloads = @arguments.keys.sort
|
|
303
309
|
@overloads.each do |overload|
|
|
304
310
|
@argument_list[overload] = @arguments[overload].keys.sort { |k1, k2| @arguments[overload][k1][:position] <=> @arguments[overload][k2][:position] }
|
|
@@ -306,10 +312,10 @@ module PLSQL
|
|
|
306
312
|
end
|
|
307
313
|
end
|
|
308
314
|
|
|
309
|
-
def ensure_tmp_tables_created(overload)
|
|
315
|
+
def ensure_tmp_tables_created(overload) # :nodoc:
|
|
310
316
|
return if @tmp_tables_created.nil? || @tmp_tables_created[overload]
|
|
311
317
|
@tmp_table_names[overload] && @tmp_table_names[overload].each do |table_name, argument_metadata|
|
|
312
|
-
sql = "CREATE GLOBAL TEMPORARY TABLE #{table_name} (\n"
|
|
318
|
+
sql = +"CREATE GLOBAL TEMPORARY TABLE #{table_name} (\n"
|
|
313
319
|
element_metadata = argument_metadata[:element]
|
|
314
320
|
case element_metadata[:data_type]
|
|
315
321
|
when "PL/SQL RECORD"
|
|
@@ -330,7 +336,7 @@ module PLSQL
|
|
|
330
336
|
@tmp_tables_created[overload] = true
|
|
331
337
|
end
|
|
332
338
|
|
|
333
|
-
def build_sql_type_name(type_owner, type_package, type_name)
|
|
339
|
+
def build_sql_type_name(type_owner, type_package, type_name) # :nodoc:
|
|
334
340
|
if type_owner == nil || type_owner == "PUBLIC"
|
|
335
341
|
type_owner_res = ""
|
|
336
342
|
else
|
|
@@ -345,7 +351,7 @@ module PLSQL
|
|
|
345
351
|
type_name_res && "#{type_owner_res}#{type_name_res}"
|
|
346
352
|
end
|
|
347
353
|
|
|
348
|
-
def get_field_definitions(argument_metadata)
|
|
354
|
+
def get_field_definitions(argument_metadata) # :nodoc:
|
|
349
355
|
fields = {}
|
|
350
356
|
case argument_metadata[:type_object_type]
|
|
351
357
|
when "PACKAGE"
|
|
@@ -359,6 +365,9 @@ module PLSQL
|
|
|
359
365
|
|
|
360
366
|
attr_no, attr_name, attr_type_owner, attr_type_name, attr_type_package, attr_length, attr_precision, attr_scale, attr_char_used = r
|
|
361
367
|
|
|
368
|
+
# Oracle 23c reports BOOLEAN as "BOOLEAN" instead of "PL/SQL BOOLEAN"
|
|
369
|
+
attr_type_name = "PL/SQL BOOLEAN" if attr_type_name == "BOOLEAN"
|
|
370
|
+
|
|
362
371
|
fields[attr_name.downcase.to_sym] = {
|
|
363
372
|
position: attr_no.to_i,
|
|
364
373
|
data_type: attr_type_owner == nil ? attr_type_name : get_composite_type(attr_type_owner, attr_type_name, attr_type_package),
|
|
@@ -408,7 +417,7 @@ module PLSQL
|
|
|
408
417
|
fields
|
|
409
418
|
end
|
|
410
419
|
|
|
411
|
-
def get_element_definition(argument_metadata)
|
|
420
|
+
def get_element_definition(argument_metadata) # :nodoc:
|
|
412
421
|
element_metadata = {}
|
|
413
422
|
if collection_type?(argument_metadata[:data_type])
|
|
414
423
|
case argument_metadata[:type_object_type]
|
|
@@ -421,6 +430,9 @@ module PLSQL
|
|
|
421
430
|
|
|
422
431
|
elem_type_owner, elem_type_name, elem_type_package, elem_length, elem_precision, elem_scale, elem_char_used, index_by = r
|
|
423
432
|
|
|
433
|
+
# Oracle 23c reports BOOLEAN as "BOOLEAN" instead of "PL/SQL BOOLEAN"
|
|
434
|
+
elem_type_name = "PL/SQL BOOLEAN" if elem_type_name == "BOOLEAN"
|
|
435
|
+
|
|
424
436
|
if index_by == "VARCHAR2"
|
|
425
437
|
raise ArgumentError, "Index-by Varchar-Table (associative array) #{argument_metadata[:type_name]} is not supported"
|
|
426
438
|
end
|
|
@@ -458,6 +470,9 @@ module PLSQL
|
|
|
458
470
|
)
|
|
459
471
|
elem_type_owner, elem_type_name, elem_length, elem_precision, elem_scale, elem_char_used = r
|
|
460
472
|
|
|
473
|
+
# Oracle 23c reports BOOLEAN as "BOOLEAN" instead of "PL/SQL BOOLEAN"
|
|
474
|
+
elem_type_name = "PL/SQL BOOLEAN" if elem_type_name == "BOOLEAN"
|
|
475
|
+
|
|
461
476
|
element_metadata = {
|
|
462
477
|
position: 1,
|
|
463
478
|
data_type: elem_type_owner == nil ? elem_type_name : "OBJECT",
|
|
@@ -510,21 +525,21 @@ module PLSQL
|
|
|
510
525
|
end
|
|
511
526
|
|
|
512
527
|
PLSQL_COMPOSITE_TYPES = ["PL/SQL RECORD", "PL/SQL TABLE", "TABLE", "VARRAY", "REF CURSOR"].freeze
|
|
513
|
-
def composite_type?(data_type)
|
|
528
|
+
def composite_type?(data_type) # :nodoc:
|
|
514
529
|
PLSQL_COMPOSITE_TYPES.include? data_type
|
|
515
530
|
end
|
|
516
531
|
|
|
517
532
|
PLSQL_COLLECTION_TYPES = ["PL/SQL TABLE", "TABLE", "VARRAY"].freeze
|
|
518
|
-
def collection_type?(data_type)
|
|
533
|
+
def collection_type?(data_type) # :nodoc:
|
|
519
534
|
PLSQL_COLLECTION_TYPES.include? data_type
|
|
520
535
|
end
|
|
521
536
|
|
|
522
|
-
def overloaded?
|
|
537
|
+
def overloaded? # :nodoc:
|
|
523
538
|
@overloaded
|
|
524
539
|
end
|
|
525
540
|
end
|
|
526
541
|
|
|
527
|
-
class Procedure
|
|
542
|
+
class Procedure # :nodoc:
|
|
528
543
|
extend ProcedureClassMethods
|
|
529
544
|
include ProcedureCommon
|
|
530
545
|
|
data/lib/plsql/procedure_call.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module PLSQL
|
|
2
|
-
class ProcedureCall
|
|
2
|
+
class ProcedureCall # :nodoc:
|
|
3
3
|
def initialize(procedure, args = [], options = {})
|
|
4
4
|
@procedure = procedure
|
|
5
5
|
@schema = @procedure.schema
|
|
@@ -115,7 +115,7 @@ module PLSQL
|
|
|
115
115
|
MATCHING_TYPES = {
|
|
116
116
|
integer: ["NUMBER", "NATURAL", "NATURALN", "POSITIVE", "POSITIVEN", "SIGNTYPE", "SIMPLE_INTEGER", "PLS_INTEGER", "BINARY_INTEGER"],
|
|
117
117
|
decimal: ["NUMBER", "BINARY_FLOAT", "BINARY_DOUBLE"],
|
|
118
|
-
string: ["VARCHAR", "VARCHAR2", "NVARCHAR2", "CHAR", "NCHAR", "CLOB", "BLOB", "XMLTYPE"],
|
|
118
|
+
string: ["VARCHAR", "VARCHAR2", "NVARCHAR2", "CHAR", "NCHAR", "CLOB", "BLOB", "XMLTYPE", "OPAQUE/XMLTYPE"],
|
|
119
119
|
date: ["DATE"],
|
|
120
120
|
time: ["DATE", "TIMESTAMP", "TIMESTAMP WITH TIME ZONE", "TIMESTAMP WITH LOCAL TIME ZONE"],
|
|
121
121
|
boolean: ["PL/SQL BOOLEAN"],
|
|
@@ -149,10 +149,10 @@ module PLSQL
|
|
|
149
149
|
end
|
|
150
150
|
|
|
151
151
|
def construct_sql(args)
|
|
152
|
-
@declare_sql = ""
|
|
153
|
-
@assignment_sql = ""
|
|
154
|
-
@call_sql = ""
|
|
155
|
-
@return_sql = ""
|
|
152
|
+
@declare_sql = +""
|
|
153
|
+
@assignment_sql = +""
|
|
154
|
+
@call_sql = +""
|
|
155
|
+
@return_sql = +""
|
|
156
156
|
@return_vars = []
|
|
157
157
|
@return_vars_metadata = {}
|
|
158
158
|
|
|
@@ -218,7 +218,7 @@ module PLSQL
|
|
|
218
218
|
end
|
|
219
219
|
add_out_variables
|
|
220
220
|
|
|
221
|
-
@sql = @declare_sql.empty? ? "" : "DECLARE\n" << @declare_sql
|
|
221
|
+
@sql = @declare_sql.empty? ? +"" : +"DECLARE\n" << @declare_sql
|
|
222
222
|
@sql << "BEGIN\n" << @assignment_sql << dbms_output_enable_sql << @call_sql << @return_sql << "END;\n"
|
|
223
223
|
end
|
|
224
224
|
|
|
@@ -240,8 +240,8 @@ module PLSQL
|
|
|
240
240
|
@bind_values[argument] = value.nil? ? nil : (value ? 1 : 0)
|
|
241
241
|
@bind_metadata[argument] = argument_metadata.merge(data_type: "NUMBER", data_precision: 1)
|
|
242
242
|
"l_#{argument}"
|
|
243
|
-
when "UNDEFINED"
|
|
244
|
-
if argument_metadata[:type_name] == "XMLTYPE"
|
|
243
|
+
when "UNDEFINED", "XMLTYPE", "OPAQUE/XMLTYPE"
|
|
244
|
+
if argument_metadata[:type_name] == "XMLTYPE" || argument_metadata[:data_type] =~ /XMLTYPE/
|
|
245
245
|
@declare_sql << "l_#{argument} XMLTYPE;\n"
|
|
246
246
|
@assignment_sql << "l_#{argument} := XMLTYPE(:#{argument});\n" if not value.nil?
|
|
247
247
|
@bind_values[argument] = value if not value.nil?
|
|
@@ -326,7 +326,7 @@ module PLSQL
|
|
|
326
326
|
"l_#{argument} #{argument_metadata[:sql_type_name]};\n"
|
|
327
327
|
else
|
|
328
328
|
fields_metadata = argument_metadata[:fields]
|
|
329
|
-
sql = "TYPE t_#{argument} IS RECORD (\n"
|
|
329
|
+
sql = +"TYPE t_#{argument} IS RECORD (\n"
|
|
330
330
|
sql << record_fields_sorted_by_position(fields_metadata).map do |field|
|
|
331
331
|
metadata = fields_metadata[field]
|
|
332
332
|
"#{field} #{type_to_sql(metadata)}"
|
|
@@ -341,7 +341,7 @@ module PLSQL
|
|
|
341
341
|
end
|
|
342
342
|
|
|
343
343
|
def record_assignment_sql_values_metadata(argument, argument_metadata, record_value)
|
|
344
|
-
sql = ""
|
|
344
|
+
sql = +""
|
|
345
345
|
bind_values = {}
|
|
346
346
|
bind_metadata = {}
|
|
347
347
|
(record_value || {}).each do |key, value|
|
|
@@ -395,8 +395,8 @@ module PLSQL
|
|
|
395
395
|
end
|
|
396
396
|
end
|
|
397
397
|
"l_#{argument} := " if is_return_value
|
|
398
|
-
when "UNDEFINED"
|
|
399
|
-
if argument_metadata[:type_name] == "XMLTYPE"
|
|
398
|
+
when "UNDEFINED", "XMLTYPE", "OPAQUE/XMLTYPE"
|
|
399
|
+
if argument_metadata[:type_name] == "XMLTYPE" || argument_metadata[:data_type] =~ /XMLTYPE/
|
|
400
400
|
@declare_sql << "l_#{argument} XMLTYPE;\n" if is_return_value
|
|
401
401
|
bind_variable = :"o_#{argument}"
|
|
402
402
|
@return_vars << bind_variable
|
|
@@ -517,8 +517,8 @@ module PLSQL
|
|
|
517
517
|
when "PL/SQL BOOLEAN"
|
|
518
518
|
numeric_value = @cursor[":o_#{argument}"]
|
|
519
519
|
numeric_value.nil? ? nil : numeric_value == 1
|
|
520
|
-
when "UNDEFINED"
|
|
521
|
-
if argument_metadata[:type_name] == "XMLTYPE"
|
|
520
|
+
when "UNDEFINED", "XMLTYPE", "OPAQUE/XMLTYPE"
|
|
521
|
+
if argument_metadata[:type_name] == "XMLTYPE" || argument_metadata[:data_type] =~ /XMLTYPE/
|
|
522
522
|
@cursor[":o_#{argument}"]
|
|
523
523
|
end
|
|
524
524
|
else
|
data/lib/plsql/schema.rb
CHANGED
|
@@ -4,8 +4,8 @@ module PLSQL
|
|
|
4
4
|
|
|
5
5
|
@@schemas = {}
|
|
6
6
|
|
|
7
|
-
class <<self
|
|
8
|
-
def find_or_new(connection_alias)
|
|
7
|
+
class << self
|
|
8
|
+
def find_or_new(connection_alias) # :nodoc:
|
|
9
9
|
connection_alias ||= :default
|
|
10
10
|
if @@schemas[connection_alias]
|
|
11
11
|
@@schemas[connection_alias]
|
|
@@ -15,7 +15,7 @@ module PLSQL
|
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def initialize(raw_conn = nil, schema = nil, original_schema = nil)
|
|
18
|
+
def initialize(raw_conn = nil, schema = nil, original_schema = nil) # :nodoc:
|
|
19
19
|
self.connection = raw_conn
|
|
20
20
|
@schema_name = schema ? schema.to_s.upcase : nil
|
|
21
21
|
@original_schema = original_schema
|
|
@@ -25,11 +25,11 @@ module PLSQL
|
|
|
25
25
|
# Returns connection wrapper object (this is not raw OCI8 or JDBC connection!)
|
|
26
26
|
attr_reader :connection
|
|
27
27
|
|
|
28
|
-
def root_schema
|
|
28
|
+
def root_schema # :nodoc:
|
|
29
29
|
@original_schema || self
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
def raw_connection=(raw_conn)
|
|
32
|
+
def raw_connection=(raw_conn) # :nodoc:
|
|
33
33
|
@connection = raw_conn ? Connection.create(raw_conn) : nil
|
|
34
34
|
reset_instance_variables
|
|
35
35
|
end
|
|
@@ -99,8 +99,12 @@ module PLSQL
|
|
|
99
99
|
@original_schema.default_timezone
|
|
100
100
|
else
|
|
101
101
|
@default_timezone ||
|
|
102
|
-
# Use ActiveRecord
|
|
103
|
-
|
|
102
|
+
# Use ActiveRecord default_timezone when ActiveRecord connection is used,
|
|
103
|
+
# preferring the connection's activerecord_class so a subclass override
|
|
104
|
+
# (available in AR < 8.0) is honored before falling back to the
|
|
105
|
+
# module-level accessor (AR 7.0+; the only one in AR 8.0+).
|
|
106
|
+
(@connection && (ar_class = @connection.activerecord_class) &&
|
|
107
|
+
(ar_class.respond_to?(:default_timezone) ? ar_class.default_timezone : ActiveRecord.default_timezone)) ||
|
|
104
108
|
# default to local timezone
|
|
105
109
|
:local
|
|
106
110
|
end
|
|
@@ -117,7 +121,7 @@ module PLSQL
|
|
|
117
121
|
|
|
118
122
|
# Same implementation as for ActiveRecord
|
|
119
123
|
# DateTimes aren't aware of DST rules, so use a consistent non-DST offset when creating a DateTime with an offset in the local zone
|
|
120
|
-
def local_timezone_offset
|
|
124
|
+
def local_timezone_offset # :nodoc:
|
|
121
125
|
::Time.local(2007).utc_offset.to_r / 86400
|
|
122
126
|
end
|
|
123
127
|
|
|
@@ -234,7 +238,7 @@ module PLSQL
|
|
|
234
238
|
end
|
|
235
239
|
|
|
236
240
|
def _errors(object_schema_name, object_name, object_type)
|
|
237
|
-
result = ""
|
|
241
|
+
result = +""
|
|
238
242
|
previous_line = 0
|
|
239
243
|
select_all(
|
|
240
244
|
"SELECT e.line, e.position, e.text error_text, s.text source_text
|
data/lib/plsql/sequence.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module PLSQL
|
|
2
|
-
module SequenceClassMethods
|
|
2
|
+
module SequenceClassMethods # :nodoc:
|
|
3
3
|
def find(schema, sequence)
|
|
4
4
|
if schema.select_first(
|
|
5
5
|
"SELECT sequence_name FROM all_sequences
|
|
@@ -27,7 +27,7 @@ module PLSQL
|
|
|
27
27
|
class Sequence
|
|
28
28
|
extend SequenceClassMethods
|
|
29
29
|
|
|
30
|
-
def initialize(schema, sequence, override_schema_name = nil)
|
|
30
|
+
def initialize(schema, sequence, override_schema_name = nil) # :nodoc:
|
|
31
31
|
@schema = schema
|
|
32
32
|
@schema_name = override_schema_name || schema.schema_name
|
|
33
33
|
@sequence_name = sequence.to_s.upcase
|
data/lib/plsql/table.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module PLSQL
|
|
2
|
-
module TableClassMethods
|
|
2
|
+
module TableClassMethods # :nodoc:
|
|
3
3
|
def find(schema, table)
|
|
4
4
|
if schema.select_first(
|
|
5
5
|
"SELECT table_name FROM all_tables
|
|
@@ -33,9 +33,9 @@ module PLSQL
|
|
|
33
33
|
class Table
|
|
34
34
|
extend TableClassMethods
|
|
35
35
|
|
|
36
|
-
attr_reader :columns, :schema_name, :table_name
|
|
36
|
+
attr_reader :columns, :schema_name, :table_name # :nodoc:
|
|
37
37
|
|
|
38
|
-
def initialize(schema, table, override_schema_name = nil)
|
|
38
|
+
def initialize(schema, table, override_schema_name = nil) # :nodoc:
|
|
39
39
|
@schema = schema
|
|
40
40
|
@schema_name = override_schema_name || schema.schema_name
|
|
41
41
|
@table_name = table.to_s.upcase
|
|
@@ -87,9 +87,9 @@ module PLSQL
|
|
|
87
87
|
def select(first_or_all, sql_params = "", *bindvars)
|
|
88
88
|
case first_or_all
|
|
89
89
|
when :first, :all
|
|
90
|
-
select_sql = "SELECT * "
|
|
90
|
+
select_sql = +"SELECT * "
|
|
91
91
|
when :count
|
|
92
|
-
select_sql = "SELECT COUNT(*) "
|
|
92
|
+
select_sql = +"SELECT COUNT(*) "
|
|
93
93
|
else
|
|
94
94
|
raise ArgumentError, "Only :first, :all or :count are supported"
|
|
95
95
|
end
|
|
@@ -251,7 +251,7 @@ module PLSQL
|
|
|
251
251
|
end
|
|
252
252
|
|
|
253
253
|
# wrapper class to simulate Procedure class for ProcedureClass#exec
|
|
254
|
-
class TableProcedure
|
|
254
|
+
class TableProcedure # :nodoc:
|
|
255
255
|
attr_reader :arguments, :argument_list, :return, :out_list, :schema
|
|
256
256
|
|
|
257
257
|
def initialize(schema, table, operation)
|
data/lib/plsql/type.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module PLSQL
|
|
2
|
-
module TypeClassMethods
|
|
2
|
+
module TypeClassMethods # :nodoc:
|
|
3
3
|
def find(schema, type)
|
|
4
4
|
if schema.select_first(
|
|
5
5
|
"SELECT type_name FROM all_types
|
|
@@ -33,9 +33,9 @@ module PLSQL
|
|
|
33
33
|
class Type
|
|
34
34
|
extend TypeClassMethods
|
|
35
35
|
|
|
36
|
-
attr_reader :typecode, :attributes, :schema_name, :type_name, :type_object_id
|
|
36
|
+
attr_reader :typecode, :attributes, :schema_name, :type_name, :type_object_id # :nodoc:
|
|
37
37
|
|
|
38
|
-
def initialize(schema, type, override_schema_name = nil)
|
|
38
|
+
def initialize(schema, type, override_schema_name = nil) # :nodoc:
|
|
39
39
|
@schema = schema
|
|
40
40
|
@schema_name = override_schema_name || schema.schema_name
|
|
41
41
|
@type_name = type.to_s.upcase
|
|
@@ -107,7 +107,7 @@ module PLSQL
|
|
|
107
107
|
end
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
def method_missing(method, *args, &block)
|
|
110
|
+
def method_missing(method, *args, &block) # :nodoc:
|
|
111
111
|
if procedure = find_procedure(method)
|
|
112
112
|
procedure.exec_with_options(args, {}, &block)
|
|
113
113
|
else
|
|
@@ -115,7 +115,7 @@ module PLSQL
|
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
117
|
|
|
118
|
-
def find_procedure(new_or_procedure)
|
|
118
|
+
def find_procedure(new_or_procedure) # :nodoc:
|
|
119
119
|
@type_procedures[new_or_procedure] ||= begin
|
|
120
120
|
procedure_name = new_or_procedure == :new ? @type_name : new_or_procedure
|
|
121
121
|
# find defined procedure for type
|
|
@@ -134,7 +134,7 @@ module PLSQL
|
|
|
134
134
|
end
|
|
135
135
|
|
|
136
136
|
# wrapper class to simulate Procedure class for ProcedureClass#exec
|
|
137
|
-
class TypeProcedure
|
|
137
|
+
class TypeProcedure # :nodoc:
|
|
138
138
|
include ProcedureCommon
|
|
139
139
|
|
|
140
140
|
def initialize(schema, type, procedure)
|
|
@@ -250,7 +250,7 @@ module PLSQL
|
|
|
250
250
|
end
|
|
251
251
|
end
|
|
252
252
|
|
|
253
|
-
class ObjectInstance < Hash
|
|
253
|
+
class ObjectInstance < Hash # :nodoc:
|
|
254
254
|
attr_accessor :plsql_type
|
|
255
255
|
|
|
256
256
|
def self.create(type, attributes)
|