activerecord-oracle_enhanced-adapter 6.1.2 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +87 -0
- data/README.md +12 -1
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/emulation/oracle_adapter.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/column.rb +2 -2
- data/lib/active_record/connection_adapters/oracle_enhanced/connection.rb +22 -13
- data/lib/active_record/connection_adapters/oracle_enhanced/context_index.rb +3 -3
- data/lib/active_record/connection_adapters/oracle_enhanced/database_limits.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +16 -17
- data/lib/active_record/connection_adapters/oracle_enhanced/dbms_output.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +18 -9
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/lob.rb +4 -4
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +18 -18
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_quoting.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/procedures.rb +6 -6
- data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +19 -22
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb +6 -6
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +35 -27
- data/lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb +30 -29
- data/lib/active_record/connection_adapters/oracle_enhanced/type_metadata.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +124 -99
- data/lib/arel/visitors/oracle.rb +6 -2
- data/lib/arel/visitors/oracle12.rb +4 -0
- data/spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb +18 -1
- data/spec/active_record/connection_adapters/oracle_enhanced/context_index_spec.rb +2 -2
- data/spec/active_record/connection_adapters/oracle_enhanced/procedures_spec.rb +5 -5
- data/spec/active_record/connection_adapters/oracle_enhanced/schema_dumper_spec.rb +3 -3
- data/spec/active_record/connection_adapters/oracle_enhanced/schema_statements_spec.rb +5 -5
- data/spec/active_record/connection_adapters/oracle_enhanced/structure_dump_spec.rb +10 -10
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +34 -7
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +5 -5
- data/spec/active_record/oracle_enhanced/type/timestamp_spec.rb +2 -2
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28b353a0c4917c1696bc44c5c3e60565c2863fc6639e48ff71814064394497a5
|
4
|
+
data.tar.gz: bdf94614cb38f1ad7ab121f580164ccb48e974ac7f09bcce3bbdfaca7cc51ca8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0586d8753686b7f81a2b8137397fe0ab9af4f0607775f866f06e0625d9dc9eae480093bbb73f9331798dcba124b5d0b86039d06e039827281cbb05ba2e9b0dc
|
7
|
+
data.tar.gz: 90c2613d22b1705db2f82d5dca382327c3b4c36edba9ac46879441614b143e136e054eed07aebb2f12b06aac95e7d89e17021ac62dfb22f8efaa67206577d341
|
data/History.md
CHANGED
@@ -1,3 +1,90 @@
|
|
1
|
+
## 7.0.0 / 2021-12-16
|
2
|
+
* Changes and bug fixes
|
3
|
+
* Support Rails 7.0.0
|
4
|
+
|
5
|
+
## 7.0.0.rc1 / 2021-12-08
|
6
|
+
|
7
|
+
* Changes and bug fixes
|
8
|
+
* Support Rails 7.0.0.rc1
|
9
|
+
* Rails 7 requires Ruby 2.7 and prefer Ruby 3+ [#2136]
|
10
|
+
* Allow usage of JDBC statement caching by DB config parameter [#2088]
|
11
|
+
* structure dump: read column comments from all_tab_cols [#2121]
|
12
|
+
* Usage of bind variables for volatile filter conditions (3) [#2125]
|
13
|
+
* attribute should not require a connection is established [#2136]
|
14
|
+
* Allow Adapter#select_all to be performed asynchronously from a background thread pool [#2146]
|
15
|
+
* Avoid extra BindParam allocation to generate placeholder in queries [#2157]
|
16
|
+
* Address undefined method `to_i' for #<ActiveModel::Attribute::WithCastValue [#2159]
|
17
|
+
* Update Rails default branch name change [#2126]
|
18
|
+
* Optimize remove_columns to use a single SQL statement when supported [#2182]
|
19
|
+
* Refactor schema creation to extract new_foreign_key_definition [#2183]
|
20
|
+
* Address "NoMethodError: undefined method `partial_writes?'" [#2188]
|
21
|
+
* Suppress partial_writes deprecation warning [#2189]
|
22
|
+
* Make default_timezone a module instance variable [#2190]
|
23
|
+
* Define adapter type maps statically when possible [#2199]
|
24
|
+
* Rename _type_cast to type_cast [#2199]
|
25
|
+
* Rename _quote to quote [#2199]
|
26
|
+
* Always use OpenSSL constants for Digest operations [#2217]
|
27
|
+
* Refactor ActiveRecord::QueryLogs hook point [#2218]
|
28
|
+
* Enable Style/RedundantRegexpEscape cop [#2074]
|
29
|
+
* Enable Lint/DuplicateRequire cop [#2107]
|
30
|
+
* Enable Layout/SpaceBeforeBrackets cop [#2108]
|
31
|
+
* Enable Performance/BindCall cop [#2140]
|
32
|
+
* Enable Performance/StringReplacement cop [#2175]
|
33
|
+
* Enable Performance/MapCompact cop [#2176]
|
34
|
+
* Enable Layout/EndOfLine cop [#2177]
|
35
|
+
* Enable Performance/SelectMap cop [#2178]
|
36
|
+
* Enable Layout/ClosingParenthesisIndentation cop [#2193]
|
37
|
+
* Enable Style/ExplicitBlockArgument cop [#2209]
|
38
|
+
* Enable Lint/DuplicateMethods cop [#2215]
|
39
|
+
* Disable Lint/ShadowingOuterLocalVariable cop [#2137]
|
40
|
+
* Disable Layout/FirstArgumentIndentation cop [#2149]
|
41
|
+
* Opt out of SuggestExtensions message [#2133]
|
42
|
+
* Suppress RuboCop's offense [#2196]
|
43
|
+
* Support RuboCop 1.19.0 [#2204]
|
44
|
+
* Prevent from including ojdbc8.jar file to gem file [#2164]
|
45
|
+
|
46
|
+
* CI
|
47
|
+
* Disable CI against JRuby builds [#2136]
|
48
|
+
* CI against Ruby 3.0.0 [#2091]
|
49
|
+
* CI against Ruby 3.0.1 and 2.7.3 [#2173]
|
50
|
+
* CI against Ruby 3.0.2 and 2.7.4 [#2195]
|
51
|
+
* Exclude ruby-head and ruby-debug until minitest allows Ruby 3.1 [#2094]
|
52
|
+
* Address Travis CI warnings and bump Ubuntu version to 20.04 [#2086]
|
53
|
+
* Tidy up Travis CI configuration [#2116]
|
54
|
+
* Tweak representation of build matrix [#2129]
|
55
|
+
* Install Oracle JDBC driver ojdbc11.jar for GitHub Actions [#2172]
|
56
|
+
* Address guides/bug_report_templates/active_record_gem_spec.rb error [#2101]
|
57
|
+
* Use Oracle Instant Client 21.1.0.0.0 [#2205]
|
58
|
+
* Use Oracle Instant Client 21.4 [#2199]
|
59
|
+
* Use gvenzl/oracle-xe docker image [#2206]
|
60
|
+
|
61
|
+
## 6.1.5 / 2021-12-07
|
62
|
+
|
63
|
+
* Changes and bug fixes
|
64
|
+
* get root cause if something went wrong with jdbc.OracleDriver [#2180 #2181]
|
65
|
+
|
66
|
+
* CI
|
67
|
+
* Bump CRuby versions at Travis CI for release61 branch [#2192]
|
68
|
+
|
69
|
+
## 6.1.4 / 2021-04-01
|
70
|
+
|
71
|
+
* Changes and bug fixes
|
72
|
+
* Support use of ojdbc11.jar [#2155, #2168]
|
73
|
+
* Add missing default granted permission "ulimited tablespace" [#2156, #2167]
|
74
|
+
* Prevent from including ojdbc8.jar file to gem file [#2163, #2164, #2165]
|
75
|
+
* Oracle enhanced adapter 6.1.3 has been yanked since #2163
|
76
|
+
|
77
|
+
* CI
|
78
|
+
* Allow-failure CI against jruby-head for release61 branch [#2166]
|
79
|
+
|
80
|
+
## 6.1.3 / 2021-03-31
|
81
|
+
|
82
|
+
* Changes and bug fixes
|
83
|
+
* Address FrozenError (can't modify frozen Hash): error [#2139 #2151 #2160]
|
84
|
+
|
85
|
+
* CI
|
86
|
+
* CI against JRuby 9.2.15.0 [#2150]
|
87
|
+
|
1
88
|
## 6.1.2 / 2021-02-10
|
2
89
|
* Changes and bug fixes
|
3
90
|
* Fixed ORA-01935: missing user or role name with config read issue [#1943 #2135, #2142]
|
data/README.md
CHANGED
@@ -6,10 +6,21 @@ Oracle enhanced adapter for ActiveRecord
|
|
6
6
|
DESCRIPTION
|
7
7
|
-----------
|
8
8
|
|
9
|
-
Oracle enhanced ActiveRecord adapter provides Oracle database access from Ruby on Rails applications. Oracle enhanced adapter can be used from Ruby on Rails versions between 2.3.x and
|
9
|
+
Oracle enhanced ActiveRecord adapter provides Oracle database access from Ruby on Rails applications. Oracle enhanced adapter can be used from Ruby on Rails versions between 2.3.x and 7.0 and it is working with Oracle database versions 10g and higher
|
10
10
|
|
11
11
|
INSTALLATION
|
12
12
|
------------
|
13
|
+
### Rails 7.0
|
14
|
+
|
15
|
+
Oracle enhanced adapter version 7.0 supports Rails 7.0
|
16
|
+
When using Ruby on Rails version 7.0 then in Gemfile include
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
# Use oracle as the database for Active Record
|
20
|
+
gem 'activerecord-oracle_enhanced-adapter', '~> 7.0.0'
|
21
|
+
gem 'ruby-oci8' # only for CRuby users
|
22
|
+
```
|
23
|
+
|
13
24
|
### Rails 6.1
|
14
25
|
|
15
26
|
Oracle enhanced adapter version 6.1 supports Rails 6.1.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
7.0.0
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class ActiveRecord::ConnectionAdapters::OracleAdapter < ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter
|
3
|
+
class ActiveRecord::ConnectionAdapters::OracleAdapter < ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter # :nodoc:
|
4
4
|
def adapter_name
|
5
5
|
"Oracle"
|
6
6
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActiveRecord
|
4
|
-
module ConnectionAdapters
|
4
|
+
module ConnectionAdapters # :nodoc:
|
5
5
|
module OracleEnhanced
|
6
6
|
class Column < ActiveRecord::ConnectionAdapters::Column
|
7
7
|
delegate :virtual, to: :sql_type_metadata, allow_nil: true
|
8
8
|
|
9
|
-
def initialize(name, default, sql_type_metadata = nil, null = true, comment: nil)
|
9
|
+
def initialize(name, default, sql_type_metadata = nil, null = true, comment: nil) # :nodoc:
|
10
10
|
super(name, default, sql_type_metadata, null, comment: comment)
|
11
11
|
end
|
12
12
|
|
@@ -4,7 +4,7 @@ module ActiveRecord
|
|
4
4
|
module ConnectionAdapters
|
5
5
|
# interface independent methods
|
6
6
|
module OracleEnhanced
|
7
|
-
class Connection
|
7
|
+
class Connection # :nodoc:
|
8
8
|
def self.create(config)
|
9
9
|
case ORACLE_ENHANCED_CONNECTION
|
10
10
|
when :oci
|
@@ -36,25 +36,25 @@ module ActiveRecord
|
|
36
36
|
sql = <<~SQL.squish
|
37
37
|
SELECT owner, table_name, 'TABLE' name_type
|
38
38
|
FROM all_tables
|
39
|
-
WHERE owner =
|
40
|
-
AND table_name =
|
39
|
+
WHERE owner = :table_owner
|
40
|
+
AND table_name = :table_name
|
41
41
|
UNION ALL
|
42
42
|
SELECT owner, view_name table_name, 'VIEW' name_type
|
43
43
|
FROM all_views
|
44
|
-
WHERE owner =
|
45
|
-
AND view_name =
|
44
|
+
WHERE owner = :table_owner
|
45
|
+
AND view_name = :table_name
|
46
46
|
UNION ALL
|
47
47
|
SELECT table_owner, table_name, 'SYNONYM' name_type
|
48
48
|
FROM all_synonyms
|
49
|
-
WHERE owner =
|
50
|
-
AND synonym_name =
|
49
|
+
WHERE owner = :table_owner
|
50
|
+
AND synonym_name = :table_name
|
51
51
|
UNION ALL
|
52
52
|
SELECT table_owner, table_name, 'SYNONYM' name_type
|
53
53
|
FROM all_synonyms
|
54
54
|
WHERE owner = 'PUBLIC'
|
55
|
-
AND synonym_name =
|
55
|
+
AND synonym_name = :real_name
|
56
56
|
SQL
|
57
|
-
if result = _select_one(sql)
|
57
|
+
if result = _select_one(sql, "CONNECTION", [table_owner, table_name, table_owner, table_name, table_owner, table_name, real_name])
|
58
58
|
case result["name_type"]
|
59
59
|
when "SYNONYM"
|
60
60
|
describe("#{result['owner'] && "#{result['owner']}."}#{result['table_name']}")
|
@@ -92,14 +92,23 @@ module ActiveRecord
|
|
92
92
|
|
93
93
|
# Returns a record hash with the column names as keys and column values
|
94
94
|
# as values.
|
95
|
+
# binds is a array of native values in contrast to ActiveRecord::Relation::QueryAttribute
|
95
96
|
def _select_one(arel, name = nil, binds = [])
|
96
|
-
|
97
|
-
|
97
|
+
cursor = prepare(arel)
|
98
|
+
cursor.bind_params(binds)
|
99
|
+
cursor.exec
|
100
|
+
columns = cursor.get_col_names.map do |col_name|
|
101
|
+
_oracle_downcase(col_name)
|
102
|
+
end
|
103
|
+
row = cursor.fetch
|
104
|
+
columns.each_with_index.map { |x, i| [x, row[i]] }.to_h if row
|
105
|
+
ensure
|
106
|
+
cursor.close
|
98
107
|
end
|
99
108
|
|
100
109
|
# Returns a single value from a record
|
101
110
|
def _select_value(arel, name = nil, binds = [])
|
102
|
-
if result = _select_one(arel)
|
111
|
+
if result = _select_one(arel, name, binds)
|
103
112
|
result.values.first
|
104
113
|
end
|
105
114
|
end
|
@@ -109,7 +118,7 @@ module ActiveRecord
|
|
109
118
|
def database_version
|
110
119
|
raise NoMethodError, "Not implemented for this raw driver"
|
111
120
|
end
|
112
|
-
class ConnectionException < StandardError
|
121
|
+
class ConnectionException < StandardError # :nodoc:
|
113
122
|
end
|
114
123
|
end
|
115
124
|
end
|
@@ -153,14 +153,14 @@ module ActiveRecord
|
|
153
153
|
(p_rowid IN ROWID,
|
154
154
|
p_clob IN OUT NOCOPY CLOB) IS
|
155
155
|
-- add_context_index_parameters #{(column_names + select_queries).inspect}#{!options.empty? ? +', ' << options.inspect[1..-2] : ''}
|
156
|
-
|
156
|
+
#{
|
157
157
|
selected_columns.map do |cols|
|
158
158
|
cols.map do |col|
|
159
159
|
raise ArgumentError, "Alias #{col} too large, should be 28 or less characters long" unless col.length <= 28
|
160
160
|
"l_#{col} VARCHAR2(32767);\n"
|
161
161
|
end.join
|
162
162
|
end.join
|
163
|
-
|
163
|
+
} BEGIN
|
164
164
|
FOR r1 IN (
|
165
165
|
SELECT #{quoted_column_names.join(', ')}
|
166
166
|
FROM #{quoted_table_name}
|
@@ -194,7 +194,7 @@ module ActiveRecord
|
|
194
194
|
"DBMS_LOB.WRITEAPPEND(p_clob, #{col.length + 3}, '</#{col}>');\n"
|
195
195
|
end.join)
|
196
196
|
end.join)
|
197
|
-
|
197
|
+
}
|
198
198
|
END LOOP;
|
199
199
|
END;
|
200
200
|
SQL
|
@@ -9,19 +9,18 @@ module ActiveRecord
|
|
9
9
|
# see: abstract/database_statements.rb
|
10
10
|
|
11
11
|
# Executes a SQL statement
|
12
|
-
def execute(sql, name = nil)
|
13
|
-
|
14
|
-
end
|
12
|
+
def execute(sql, name = nil, async: false)
|
13
|
+
sql = transform_query(sql)
|
15
14
|
|
16
|
-
|
17
|
-
reload_type_map
|
18
|
-
super
|
15
|
+
log(sql, name, async: async) { @connection.exec(sql) }
|
19
16
|
end
|
20
17
|
|
21
|
-
def exec_query(sql, name = "SQL", binds = [], prepare: false)
|
18
|
+
def exec_query(sql, name = "SQL", binds = [], prepare: false, async: false)
|
19
|
+
sql = transform_query(sql)
|
20
|
+
|
22
21
|
type_casted_binds = type_casted_binds(binds)
|
23
22
|
|
24
|
-
log(sql, name, binds, type_casted_binds) do
|
23
|
+
log(sql, name, binds, type_casted_binds, async: async) do
|
25
24
|
cursor = nil
|
26
25
|
cached = false
|
27
26
|
with_retry do
|
@@ -79,7 +78,7 @@ module ActiveRecord
|
|
79
78
|
# New method in ActiveRecord 3.1
|
80
79
|
# Will add RETURNING clause in case of trigger generated primary keys
|
81
80
|
def sql_for_insert(sql, pk, binds)
|
82
|
-
unless pk == false || pk.nil? || pk.is_a?(Array)
|
81
|
+
unless pk == false || pk.nil? || pk.is_a?(Array) || pk.is_a?(String)
|
83
82
|
sql = "#{sql} RETURNING #{quote_column_name(pk)} INTO :returning_id"
|
84
83
|
(binds = binds.dup) << ActiveRecord::Relation::QueryAttribute.new("returning_id", nil, Type::OracleEnhanced::Integer.new)
|
85
84
|
end
|
@@ -164,7 +163,7 @@ module ActiveRecord
|
|
164
163
|
|
165
164
|
alias :exec_delete :exec_update
|
166
165
|
|
167
|
-
def begin_db_transaction
|
166
|
+
def begin_db_transaction # :nodoc:
|
168
167
|
@connection.autocommit = false
|
169
168
|
end
|
170
169
|
|
@@ -183,27 +182,27 @@ module ActiveRecord
|
|
183
182
|
execute "SET TRANSACTION ISOLATION LEVEL #{transaction_isolation_levels.fetch(isolation)}"
|
184
183
|
end
|
185
184
|
|
186
|
-
def commit_db_transaction
|
185
|
+
def commit_db_transaction # :nodoc:
|
187
186
|
@connection.commit
|
188
187
|
ensure
|
189
188
|
@connection.autocommit = true
|
190
189
|
end
|
191
190
|
|
192
|
-
def exec_rollback_db_transaction
|
191
|
+
def exec_rollback_db_transaction # :nodoc:
|
193
192
|
@connection.rollback
|
194
193
|
ensure
|
195
194
|
@connection.autocommit = true
|
196
195
|
end
|
197
196
|
|
198
|
-
def create_savepoint(name = current_savepoint_name)
|
197
|
+
def create_savepoint(name = current_savepoint_name) # :nodoc:
|
199
198
|
execute("SAVEPOINT #{name}", "TRANSACTION")
|
200
199
|
end
|
201
200
|
|
202
|
-
def exec_rollback_to_savepoint(name = current_savepoint_name)
|
201
|
+
def exec_rollback_to_savepoint(name = current_savepoint_name) # :nodoc:
|
203
202
|
execute("ROLLBACK TO #{name}", "TRANSACTION")
|
204
203
|
end
|
205
204
|
|
206
|
-
def release_savepoint(name = current_savepoint_name)
|
205
|
+
def release_savepoint(name = current_savepoint_name) # :nodoc:
|
207
206
|
# there is no RELEASE SAVEPOINT statement in Oracle
|
208
207
|
end
|
209
208
|
|
@@ -214,7 +213,7 @@ module ActiveRecord
|
|
214
213
|
end
|
215
214
|
|
216
215
|
# Inserts the given fixture into the table. Overridden to properly handle lobs.
|
217
|
-
def insert_fixture(fixture, table_name)
|
216
|
+
def insert_fixture(fixture, table_name) # :nodoc:
|
218
217
|
super
|
219
218
|
|
220
219
|
if ActiveRecord::Base.pluralize_table_names
|
@@ -249,7 +248,7 @@ module ActiveRecord
|
|
249
248
|
end
|
250
249
|
|
251
250
|
# Writes LOB values from attributes for specified columns
|
252
|
-
def write_lobs(table_name, klass, attributes, columns)
|
251
|
+
def write_lobs(table_name, klass, attributes, columns) # :nodoc:
|
253
252
|
id = quote(attributes[klass.primary_key])
|
254
253
|
columns.each do |col|
|
255
254
|
value = attributes[col.name]
|
@@ -31,7 +31,7 @@ module ActiveRecord
|
|
31
31
|
end
|
32
32
|
|
33
33
|
private
|
34
|
-
def log(sql, name = "SQL", binds = [], type_casted_binds = [], statement_name = nil)
|
34
|
+
def log(sql, name = "SQL", binds = [], type_casted_binds = [], statement_name = nil, async: false)
|
35
35
|
super
|
36
36
|
ensure
|
37
37
|
log_dbms_output if dbms_output_enabled?
|
@@ -16,7 +16,8 @@ begin
|
|
16
16
|
# Oracle 11g client ojdbc6.jar is also compatible with Java 1.7
|
17
17
|
# Oracle 12c Release 1 client provides ojdbc7.jar
|
18
18
|
# Oracle 12c Release 2 client provides ojdbc8.jar
|
19
|
-
|
19
|
+
# Oracle 21c provides ojdbc11.jar for Java 11 and above
|
20
|
+
ojdbc_jars = %w(ojdbc11.jar ojdbc8.jar ojdbc7.jar ojdbc6.jar)
|
20
21
|
|
21
22
|
if !ENV_JAVA["java.class.path"]&.match?(Regexp.new(ojdbc_jars.join("|")))
|
22
23
|
# On Unix environment variable should be PATH, on Windows it is sometimes Path
|
@@ -42,16 +43,16 @@ begin
|
|
42
43
|
java.lang.System.set_property("oracle.net.tns_admin", ENV["TNS_ADMIN"])
|
43
44
|
end
|
44
45
|
|
45
|
-
rescue LoadError, NameError
|
46
|
+
rescue LoadError, NameError => e
|
46
47
|
# JDBC driver is unavailable.
|
47
|
-
raise LoadError, "ERROR: ActiveRecord oracle_enhanced adapter could not load Oracle JDBC driver. Please install #{ojdbc_jars.join(' or ') } library."
|
48
|
+
raise LoadError, "ERROR: ActiveRecord oracle_enhanced adapter could not load Oracle JDBC driver. Please install #{ojdbc_jars.join(' or ') } library.\n#{e.class}:#{e.message}"
|
48
49
|
end
|
49
50
|
|
50
51
|
module ActiveRecord
|
51
52
|
module ConnectionAdapters
|
52
53
|
# JDBC database interface for JRuby
|
53
54
|
module OracleEnhanced
|
54
|
-
class JDBCConnection < OracleEnhanced::Connection
|
55
|
+
class JDBCConnection < OracleEnhanced::Connection # :nodoc:
|
55
56
|
attr_accessor :active
|
56
57
|
alias :active? :active
|
57
58
|
|
@@ -98,6 +99,8 @@ module ActiveRecord
|
|
98
99
|
@raw_connection = @raw_connection.underlying_connection
|
99
100
|
end
|
100
101
|
|
102
|
+
# Workaround FrozenError (can't modify frozen Hash):
|
103
|
+
config = config.dup
|
101
104
|
config[:driver] ||= @raw_connection.meta_data.connection.java_class.name
|
102
105
|
username = @raw_connection.meta_data.user_name
|
103
106
|
else
|
@@ -113,7 +116,7 @@ module ActiveRecord
|
|
113
116
|
if database && (using_tns_alias || host == "connection-string")
|
114
117
|
url = "jdbc:oracle:thin:@#{database}"
|
115
118
|
else
|
116
|
-
unless database.match?(/^(
|
119
|
+
unless database.match?(/^(:|\/)/)
|
117
120
|
# assume database is a SID if no colon or slash are supplied (backward-compatibility)
|
118
121
|
database = "/#{database}"
|
119
122
|
end
|
@@ -142,12 +145,18 @@ module ActiveRecord
|
|
142
145
|
end
|
143
146
|
|
144
147
|
# Set session time zone to current time zone
|
145
|
-
if ActiveRecord
|
148
|
+
if ActiveRecord.default_timezone == :local
|
146
149
|
@raw_connection.setSessionTimeZone(time_zone)
|
147
|
-
elsif ActiveRecord
|
150
|
+
elsif ActiveRecord.default_timezone == :utc
|
148
151
|
@raw_connection.setSessionTimeZone("UTC")
|
149
152
|
end
|
150
153
|
|
154
|
+
if config[:jdbc_statement_cache_size]
|
155
|
+
raise "Integer value expected for :jdbc_statement_cache_size" unless config[:jdbc_statement_cache_size].instance_of? Integer
|
156
|
+
@raw_connection.setImplicitCachingEnabled(true)
|
157
|
+
@raw_connection.setStatementCacheSize(config[:jdbc_statement_cache_size])
|
158
|
+
end
|
159
|
+
|
151
160
|
# Set default number of rows to prefetch
|
152
161
|
# @raw_connection.setDefaultRowPrefetch(prefetch_rows) if prefetch_rows
|
153
162
|
end
|
@@ -489,13 +498,13 @@ module ActiveRecord
|
|
489
498
|
if dt = rset.getDATE(i)
|
490
499
|
d = dt.dateValue
|
491
500
|
t = dt.timeValue
|
492
|
-
Time.send(
|
501
|
+
Time.send(ActiveRecord.default_timezone, d.year + 1900, d.month + 1, d.date, t.hours, t.minutes, t.seconds)
|
493
502
|
else
|
494
503
|
nil
|
495
504
|
end
|
496
505
|
when :TIMESTAMP, :TIMESTAMPTZ, :TIMESTAMPLTZ, :"TIMESTAMP WITH TIME ZONE", :"TIMESTAMP WITH LOCAL TIME ZONE"
|
497
506
|
ts = rset.getTimestamp(i)
|
498
|
-
ts && Time.send(
|
507
|
+
ts && Time.send(ActiveRecord.default_timezone, ts.year + 1900, ts.month + 1, ts.date, ts.hours, ts.minutes, ts.seconds,
|
499
508
|
ts.nanos / 1000)
|
500
509
|
when :CLOB
|
501
510
|
get_lob_value ? lob_to_ruby_value(rset.getClob(i)) : rset.getClob(i)
|
@@ -4,7 +4,7 @@ module ActiveRecord
|
|
4
4
|
module ConnectionAdapters
|
5
5
|
module OracleEnhanced
|
6
6
|
module JDBCQuoting
|
7
|
-
def
|
7
|
+
def type_cast(value)
|
8
8
|
case value
|
9
9
|
when ActiveModel::Type::Binary::Data
|
10
10
|
blob = Java::OracleSql::BLOB.createTemporary(@connection.raw_connection, false, Java::OracleSql::BLOB::DURATION_SESSION)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module ActiveRecord
|
4
|
-
module ConnectionAdapters
|
5
|
-
module OracleEnhanced
|
6
|
-
module Lob
|
3
|
+
module ActiveRecord # :nodoc:
|
4
|
+
module ConnectionAdapters # :nodoc:
|
5
|
+
module OracleEnhanced # :nodoc:
|
6
|
+
module Lob # :nodoc:
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
9
|
included do
|
@@ -26,7 +26,7 @@ module ActiveRecord
|
|
26
26
|
module ConnectionAdapters
|
27
27
|
# OCI database interface for MRI
|
28
28
|
module OracleEnhanced
|
29
|
-
class OCIConnection < OracleEnhanced::Connection
|
29
|
+
class OCIConnection < OracleEnhanced::Connection # :nodoc:
|
30
30
|
def initialize(config)
|
31
31
|
@raw_connection = OCI8EnhancedAutoRecover.new(config, OracleEnhancedOCIFactory)
|
32
32
|
# default schema owner
|
@@ -289,9 +289,9 @@ module ActiveRecord
|
|
289
289
|
end
|
290
290
|
# code from Time.time_with_datetime_fallback
|
291
291
|
begin
|
292
|
-
Time.send(
|
292
|
+
Time.send(ActiveRecord.default_timezone, year, month, day, hour, min, sec, usec)
|
293
293
|
rescue
|
294
|
-
offset =
|
294
|
+
offset = ActiveRecord.default_timezone.to_sym == :local ? ::DateTime.local_offset : 0
|
295
295
|
::DateTime.civil(year, month, day, hour, min, sec, offset)
|
296
296
|
end
|
297
297
|
end
|
@@ -299,7 +299,7 @@ module ActiveRecord
|
|
299
299
|
|
300
300
|
# The OracleEnhancedOCIFactory factors out the code necessary to connect and
|
301
301
|
# configure an Oracle/OCI connection.
|
302
|
-
class OracleEnhancedOCIFactory
|
302
|
+
class OracleEnhancedOCIFactory # :nodoc:
|
303
303
|
DEFAULT_TCP_KEEPALIVE_TIME = 600
|
304
304
|
|
305
305
|
def self.new_connection(config)
|
@@ -343,9 +343,9 @@ module ActiveRecord
|
|
343
343
|
conn.non_blocking = true if async
|
344
344
|
conn.prefetch_rows = prefetch_rows
|
345
345
|
conn.exec "alter session set cursor_sharing = #{cursor_sharing}" rescue nil if cursor_sharing
|
346
|
-
if ActiveRecord
|
346
|
+
if ActiveRecord.default_timezone == :local
|
347
347
|
conn.exec "alter session set time_zone = '#{time_zone}'" unless time_zone.blank?
|
348
|
-
elsif ActiveRecord
|
348
|
+
elsif ActiveRecord.default_timezone == :utc
|
349
349
|
conn.exec "alter session set time_zone = '+00:00'"
|
350
350
|
end
|
351
351
|
conn.exec "alter session set current_schema = #{schema}" unless schema.blank?
|
@@ -375,18 +375,18 @@ end
|
|
375
375
|
# this would be dangerous (as the earlier part of the implied transaction
|
376
376
|
# may have failed silently if the connection died) -- so instead the
|
377
377
|
# connection is marked as dead, to be reconnected on it's next use.
|
378
|
-
|
379
|
-
class OCI8EnhancedAutoRecover < DelegateClass(OCI8)
|
380
|
-
attr_accessor :active
|
381
|
-
alias :active? :active
|
378
|
+
# :stopdoc:
|
379
|
+
class OCI8EnhancedAutoRecover < DelegateClass(OCI8) # :nodoc:
|
380
|
+
attr_accessor :active # :nodoc:
|
381
|
+
alias :active? :active # :nodoc:
|
382
382
|
|
383
383
|
cattr_accessor :auto_retry
|
384
384
|
class << self
|
385
|
-
alias :auto_retry? :auto_retry
|
385
|
+
alias :auto_retry? :auto_retry # :nodoc:
|
386
386
|
end
|
387
387
|
@@auto_retry = false
|
388
388
|
|
389
|
-
def initialize(config, factory)
|
389
|
+
def initialize(config, factory) # :nodoc:
|
390
390
|
@active = true
|
391
391
|
@config = config
|
392
392
|
@factory = factory
|
@@ -397,7 +397,7 @@ class OCI8EnhancedAutoRecover < DelegateClass(OCI8) #:nodoc:
|
|
397
397
|
# Checks connection, returns true if active. Note that ping actively
|
398
398
|
# checks the connection, while #active? simply returns the last
|
399
399
|
# known state.
|
400
|
-
def ping
|
400
|
+
def ping # :nodoc:
|
401
401
|
@connection.exec("select 1 from dual") { |r| nil }
|
402
402
|
@active = true
|
403
403
|
rescue
|
@@ -406,7 +406,7 @@ class OCI8EnhancedAutoRecover < DelegateClass(OCI8) #:nodoc:
|
|
406
406
|
end
|
407
407
|
|
408
408
|
# Resets connection, by logging off and creating a new connection.
|
409
|
-
def reset!
|
409
|
+
def reset! # :nodoc:
|
410
410
|
logoff rescue nil
|
411
411
|
begin
|
412
412
|
@connection = @factory.new_connection @config
|
@@ -423,10 +423,10 @@ class OCI8EnhancedAutoRecover < DelegateClass(OCI8) #:nodoc:
|
|
423
423
|
# ORA-03113: end-of-file on communication channel
|
424
424
|
# ORA-03114: not connected to ORACLE
|
425
425
|
# ORA-03135: connection lost contact
|
426
|
-
LOST_CONNECTION_ERROR_CODES = [ 28, 1012, 3113, 3114, 3135 ]
|
426
|
+
LOST_CONNECTION_ERROR_CODES = [ 28, 1012, 3113, 3114, 3135 ] # :nodoc:
|
427
427
|
|
428
428
|
# Adds auto-recovery functionality.
|
429
|
-
def with_retry
|
429
|
+
def with_retry # :nodoc:
|
430
430
|
should_retry = self.class.auto_retry? && autocommit?
|
431
431
|
|
432
432
|
begin
|
@@ -441,8 +441,8 @@ class OCI8EnhancedAutoRecover < DelegateClass(OCI8) #:nodoc:
|
|
441
441
|
end
|
442
442
|
end
|
443
443
|
|
444
|
-
def exec(sql, *bindvars, &block)
|
444
|
+
def exec(sql, *bindvars, &block) # :nodoc:
|
445
445
|
with_retry { @connection.exec(sql, *bindvars, &block) }
|
446
446
|
end
|
447
447
|
end
|
448
|
-
|
448
|
+
# :startdoc:
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "active_support"
|
4
4
|
|
5
|
-
module ActiveRecord
|
5
|
+
module ActiveRecord # :nodoc:
|
6
6
|
# Custom create, update, delete methods functionality.
|
7
7
|
#
|
8
8
|
# Example:
|
@@ -33,7 +33,7 @@ module ActiveRecord #:nodoc:
|
|
33
33
|
# end
|
34
34
|
# end
|
35
35
|
#
|
36
|
-
module OracleEnhancedProcedures
|
36
|
+
module OracleEnhancedProcedures # :nodoc:
|
37
37
|
module ClassMethods
|
38
38
|
# Specify custom create method which should be used instead of Rails generated INSERT statement.
|
39
39
|
# Provided block should return ID of new record.
|
@@ -83,7 +83,7 @@ module ActiveRecord #:nodoc:
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
def destroy
|
86
|
+
def destroy # :nodoc:
|
87
87
|
# check if class has custom delete method
|
88
88
|
if self.class.custom_delete_method
|
89
89
|
# wrap destroy in transaction
|
@@ -150,7 +150,7 @@ module ActiveRecord #:nodoc:
|
|
150
150
|
end
|
151
151
|
end
|
152
152
|
# update just dirty attributes
|
153
|
-
if
|
153
|
+
if partial_updates?
|
154
154
|
# Serialized attributes should always be written in case they've been
|
155
155
|
# changed in place.
|
156
156
|
update_using_custom_method(changed | (attributes.keys & self.class.columns.select { |column| column.is_a?(Type::Serialized) }))
|
@@ -185,8 +185,8 @@ module ActiveRecord #:nodoc:
|
|
185
185
|
freeze
|
186
186
|
end
|
187
187
|
|
188
|
-
def log_custom_method(*args)
|
189
|
-
self.class.connection.send(:log, *args)
|
188
|
+
def log_custom_method(*args, &block)
|
189
|
+
self.class.connection.send(:log, *args, &block)
|
190
190
|
end
|
191
191
|
|
192
192
|
alias_method :update_record, :_update_record if private_method_defined?(:_update_record)
|