activerecord-oracle_enhanced-adapter 6.1.4 → 7.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +78 -0
  3. data/README.md +12 -1
  4. data/VERSION +1 -1
  5. data/lib/active_record/connection_adapters/emulation/oracle_adapter.rb +1 -1
  6. data/lib/active_record/connection_adapters/oracle_enhanced/column.rb +2 -2
  7. data/lib/active_record/connection_adapters/oracle_enhanced/connection.rb +22 -13
  8. data/lib/active_record/connection_adapters/oracle_enhanced/context_index.rb +3 -3
  9. data/lib/active_record/connection_adapters/oracle_enhanced/database_limits.rb +1 -1
  10. data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +19 -22
  11. data/lib/active_record/connection_adapters/oracle_enhanced/dbms_output.rb +1 -1
  12. data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +14 -8
  13. data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb +1 -1
  14. data/lib/active_record/connection_adapters/oracle_enhanced/lob.rb +4 -4
  15. data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +18 -18
  16. data/lib/active_record/connection_adapters/oracle_enhanced/oci_quoting.rb +1 -1
  17. data/lib/active_record/connection_adapters/oracle_enhanced/procedures.rb +6 -6
  18. data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +16 -16
  19. data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +1 -1
  20. data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +1 -1
  21. data/lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb +6 -6
  22. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +37 -27
  23. data/lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb +30 -29
  24. data/lib/active_record/connection_adapters/oracle_enhanced/type_metadata.rb +1 -1
  25. data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +123 -98
  26. data/lib/arel/visitors/oracle.rb +6 -2
  27. data/lib/arel/visitors/oracle12.rb +4 -0
  28. data/spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb +18 -1
  29. data/spec/active_record/connection_adapters/oracle_enhanced/context_index_spec.rb +2 -2
  30. data/spec/active_record/connection_adapters/oracle_enhanced/procedures_spec.rb +5 -5
  31. data/spec/active_record/connection_adapters/oracle_enhanced/schema_dumper_spec.rb +3 -3
  32. data/spec/active_record/connection_adapters/oracle_enhanced/schema_statements_spec.rb +5 -5
  33. data/spec/active_record/connection_adapters/oracle_enhanced/structure_dump_spec.rb +10 -10
  34. data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +34 -7
  35. data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +5 -5
  36. data/spec/active_record/oracle_enhanced/type/custom_spec.rb +88 -0
  37. data/spec/active_record/oracle_enhanced/type/timestamp_spec.rb +2 -2
  38. metadata +22 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a0830e05dfb361ea469742a3642461cbd839ea4ca40b3c1f1bb3ec0d8443657
4
- data.tar.gz: 46c6a959835694b0a6f38dcddbba03cb23ae1b20fef66c13c53ed3eac9a1fd8d
3
+ metadata.gz: d62d90d3ee110795b7396cd404a1e9c7dd5d61b9d11685b0a935a4c93f276cd3
4
+ data.tar.gz: fb3e1420b6ed0ddcc98631da947081f69543f8fe8ac42551a4a980f39b038fd2
5
5
  SHA512:
6
- metadata.gz: 2561b2089a74bb3f4e3cb0d30a7597fe2491a41b52dfaaa68e6d8055b4c9d0e80044a6f8b720f7d40d8b5fdb9697396e29a29d2025424edb6ab178fb3612812d
7
- data.tar.gz: cff42212affbc978b55dd3683ec939b8b2381ed0fcd09e1d1c597d06c695e68bc14dbb486680fd19abfd1ced46d014a3e65b931500483554b20a0d87fb59921a
6
+ metadata.gz: 1e9ee5b06389da2923f6485412ea2753f2537c4ac7f6e2ba9afd2e8189347aa97313c9273de617f3375a593f310262902bbf7e5ffabc5fd75c44da5870026fe4
7
+ data.tar.gz: 7da3548a2d4f594b213ace0a2b3e016b44a6767c284970258db595f23dba952d83ddde919d49f1d98e2359ae74c2ac0adbb0b65ecf18bb33d67d58bb891d90b8
data/History.md CHANGED
@@ -1,3 +1,81 @@
1
+ ## 7.0.1 / 2022-01-13
2
+
3
+ * Changes and bug fixes
4
+ * Add ruby-oci8 as dependency only for CRuby [#2238 #2240 #2243]
5
+ * Add if_exists option to remove_index [#2219 #2233]
6
+ * all attributes serialized before writing [#2203 #2234]
7
+ * Require 'activerecord', not 'rails' not to attempt to install digest [#2241]
8
+ * CI
9
+ * Bump Ruby versions at Travis CI [#2242]
10
+ * CI against Ruby 3.1 at GitHub Actions [#2235 #2244]
11
+ ## 7.0.0 / 2021-12-16
12
+ * Changes and bug fixes
13
+ * Support Rails 7.0.0
14
+
15
+ ## 7.0.0.rc1 / 2021-12-08
16
+
17
+ * Changes and bug fixes
18
+ * Support Rails 7.0.0.rc1
19
+ * Rails 7 requires Ruby 2.7 and prefer Ruby 3+ [#2136]
20
+ * Allow usage of JDBC statement caching by DB config parameter [#2088]
21
+ * structure dump: read column comments from all_tab_cols [#2121]
22
+ * Usage of bind variables for volatile filter conditions (3) [#2125]
23
+ * attribute should not require a connection is established [#2136]
24
+ * Allow Adapter#select_all to be performed asynchronously from a background thread pool [#2146]
25
+ * Avoid extra BindParam allocation to generate placeholder in queries [#2157]
26
+ * Address undefined method `to_i' for #<ActiveModel::Attribute::WithCastValue [#2159]
27
+ * Update Rails default branch name change [#2126]
28
+ * Optimize remove_columns to use a single SQL statement when supported [#2182]
29
+ * Refactor schema creation to extract new_foreign_key_definition [#2183]
30
+ * Address "NoMethodError: undefined method `partial_writes?'" [#2188]
31
+ * Suppress partial_writes deprecation warning [#2189]
32
+ * Make default_timezone a module instance variable [#2190]
33
+ * Define adapter type maps statically when possible [#2199]
34
+ * Rename _type_cast to type_cast [#2199]
35
+ * Rename _quote to quote [#2199]
36
+ * Always use OpenSSL constants for Digest operations [#2217]
37
+ * Refactor ActiveRecord::QueryLogs hook point [#2218]
38
+ * Enable Style/RedundantRegexpEscape cop [#2074]
39
+ * Enable Lint/DuplicateRequire cop [#2107]
40
+ * Enable Layout/SpaceBeforeBrackets cop [#2108]
41
+ * Enable Performance/BindCall cop [#2140]
42
+ * Enable Performance/StringReplacement cop [#2175]
43
+ * Enable Performance/MapCompact cop [#2176]
44
+ * Enable Layout/EndOfLine cop [#2177]
45
+ * Enable Performance/SelectMap cop [#2178]
46
+ * Enable Layout/ClosingParenthesisIndentation cop [#2193]
47
+ * Enable Style/ExplicitBlockArgument cop [#2209]
48
+ * Enable Lint/DuplicateMethods cop [#2215]
49
+ * Disable Lint/ShadowingOuterLocalVariable cop [#2137]
50
+ * Disable Layout/FirstArgumentIndentation cop [#2149]
51
+ * Opt out of SuggestExtensions message [#2133]
52
+ * Suppress RuboCop's offense [#2196]
53
+ * Support RuboCop 1.19.0 [#2204]
54
+ * Prevent from including ojdbc8.jar file to gem file [#2164]
55
+
56
+ * CI
57
+ * Disable CI against JRuby builds [#2136]
58
+ * CI against Ruby 3.0.0 [#2091]
59
+ * CI against Ruby 3.0.1 and 2.7.3 [#2173]
60
+ * CI against Ruby 3.0.2 and 2.7.4 [#2195]
61
+ * Exclude ruby-head and ruby-debug until minitest allows Ruby 3.1 [#2094]
62
+ * Address Travis CI warnings and bump Ubuntu version to 20.04 [#2086]
63
+ * Tidy up Travis CI configuration [#2116]
64
+ * Tweak representation of build matrix [#2129]
65
+ * Install Oracle JDBC driver ojdbc11.jar for GitHub Actions [#2172]
66
+ * Address guides/bug_report_templates/active_record_gem_spec.rb error [#2101]
67
+ * Use Oracle Instant Client 21.1.0.0.0 [#2205]
68
+ * Use Oracle Instant Client 21.4 [#2199]
69
+ * Use gvenzl/oracle-xe docker image [#2206]
70
+
71
+ ## 6.1.5 / 2021-12-07
72
+
73
+ * Changes and bug fixes
74
+ * get root cause if something went wrong with jdbc.OracleDriver [#2180 #2181]
75
+
76
+ * CI
77
+ * Bump CRuby versions at Travis CI for release61 branch [#2192]
78
+
1
79
  ## 6.1.4 / 2021-04-01
2
80
 
3
81
  * Changes and bug fixes
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 6.0 and it is working with Oracle database versions 10g and higher
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
- 6.1.4
1
+ 7.0.1
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class ActiveRecord::ConnectionAdapters::OracleAdapter < ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter #:nodoc:
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 #:nodoc:
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) #:nodoc:
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 #:nodoc:
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 = '#{table_owner}'
40
- AND table_name = '#{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 = '#{table_owner}'
45
- AND view_name = '#{table_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 = '#{table_owner}'
50
- AND synonym_name = '#{table_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 = '#{real_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
- result = select(arel)
97
- result.first if result
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 #:nodoc:
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
- } BEGIN
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,7 +9,7 @@ module ActiveRecord
9
9
  # maximum length of Oracle identifiers
10
10
  IDENTIFIER_MAX_LENGTH = 30
11
11
 
12
- def table_alias_length #:nodoc:
12
+ def table_alias_length # :nodoc:
13
13
  IDENTIFIER_MAX_LENGTH
14
14
  end
15
15
 
@@ -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
- log(sql, name) { @connection.exec(sql) }
14
- end
12
+ def execute(sql, name = nil, async: false)
13
+ sql = transform_query(sql)
15
14
 
16
- def clear_cache! # :nodoc:
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 #:nodoc:
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 #:nodoc:
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 #:nodoc:
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) #:nodoc:
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) #:nodoc:
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) #:nodoc:
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) #:nodoc:
216
+ def insert_fixture(fixture, table_name) # :nodoc:
218
217
  super
219
218
 
220
219
  if ActiveRecord::Base.pluralize_table_names
@@ -249,17 +248,15 @@ 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) #:nodoc:
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]
256
255
  # changed sequence of next two lines - should check if value is nil before converting to yaml
257
256
  next unless value
258
- if klass.attribute_types[col.name].is_a? Type::Serialized
259
- value = klass.attribute_types[col.name].serialize(value)
260
- # value can be nil after serialization because ActiveRecord serializes [] and {} as nil
261
- next unless value
262
- end
257
+ value = klass.attribute_types[col.name].serialize(value)
258
+ # value can be nil after serialization because ActiveRecord serializes [] and {} as nil
259
+ next unless value
263
260
  uncached do
264
261
  unless lob_record = select_one(sql = <<~SQL.squish, "Writable Large Object")
265
262
  SELECT #{quote_column_name(col.name)} FROM #{quote_table_name(table_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?
@@ -43,16 +43,16 @@ begin
43
43
  java.lang.System.set_property("oracle.net.tns_admin", ENV["TNS_ADMIN"])
44
44
  end
45
45
 
46
- rescue LoadError, NameError
46
+ rescue LoadError, NameError => e
47
47
  # JDBC driver is unavailable.
48
- 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}"
49
49
  end
50
50
 
51
51
  module ActiveRecord
52
52
  module ConnectionAdapters
53
53
  # JDBC database interface for JRuby
54
54
  module OracleEnhanced
55
- class JDBCConnection < OracleEnhanced::Connection #:nodoc:
55
+ class JDBCConnection < OracleEnhanced::Connection # :nodoc:
56
56
  attr_accessor :active
57
57
  alias :active? :active
58
58
 
@@ -116,7 +116,7 @@ module ActiveRecord
116
116
  if database && (using_tns_alias || host == "connection-string")
117
117
  url = "jdbc:oracle:thin:@#{database}"
118
118
  else
119
- unless database.match?(/^(\:|\/)/)
119
+ unless database.match?(/^(:|\/)/)
120
120
  # assume database is a SID if no colon or slash are supplied (backward-compatibility)
121
121
  database = "/#{database}"
122
122
  end
@@ -145,12 +145,18 @@ module ActiveRecord
145
145
  end
146
146
 
147
147
  # Set session time zone to current time zone
148
- if ActiveRecord::Base.default_timezone == :local
148
+ if ActiveRecord.default_timezone == :local
149
149
  @raw_connection.setSessionTimeZone(time_zone)
150
- elsif ActiveRecord::Base.default_timezone == :utc
150
+ elsif ActiveRecord.default_timezone == :utc
151
151
  @raw_connection.setSessionTimeZone("UTC")
152
152
  end
153
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
+
154
160
  # Set default number of rows to prefetch
155
161
  # @raw_connection.setDefaultRowPrefetch(prefetch_rows) if prefetch_rows
156
162
  end
@@ -492,13 +498,13 @@ module ActiveRecord
492
498
  if dt = rset.getDATE(i)
493
499
  d = dt.dateValue
494
500
  t = dt.timeValue
495
- Time.send(Base.default_timezone, d.year + 1900, d.month + 1, d.date, t.hours, t.minutes, t.seconds)
501
+ Time.send(ActiveRecord.default_timezone, d.year + 1900, d.month + 1, d.date, t.hours, t.minutes, t.seconds)
496
502
  else
497
503
  nil
498
504
  end
499
505
  when :TIMESTAMP, :TIMESTAMPTZ, :TIMESTAMPLTZ, :"TIMESTAMP WITH TIME ZONE", :"TIMESTAMP WITH LOCAL TIME ZONE"
500
506
  ts = rset.getTimestamp(i)
501
- ts && Time.send(Base.default_timezone, ts.year + 1900, ts.month + 1, ts.date, ts.hours, ts.minutes, ts.seconds,
507
+ ts && Time.send(ActiveRecord.default_timezone, ts.year + 1900, ts.month + 1, ts.date, ts.hours, ts.minutes, ts.seconds,
502
508
  ts.nanos / 1000)
503
509
  when :CLOB
504
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 _type_cast(value)
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 #:nodoc:
4
- module ConnectionAdapters #:nodoc:
5
- module OracleEnhanced #:nodoc:
6
- module Lob #:nodoc:
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 #:nodoc:
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(Base.default_timezone, year, month, day, hour, min, sec, usec)
292
+ Time.send(ActiveRecord.default_timezone, year, month, day, hour, min, sec, usec)
293
293
  rescue
294
- offset = Base.default_timezone.to_sym == :local ? ::DateTime.local_offset : 0
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 #:nodoc:
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::Base.default_timezone == :local
346
+ if ActiveRecord.default_timezone == :local
347
347
  conn.exec "alter session set time_zone = '#{time_zone}'" unless time_zone.blank?
348
- elsif ActiveRecord::Base.default_timezone == :utc
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
- #:stopdoc:
379
- class OCI8EnhancedAutoRecover < DelegateClass(OCI8) #:nodoc:
380
- attr_accessor :active #:nodoc:
381
- alias :active? :active #:nodoc:
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 #:nodoc:
385
+ alias :auto_retry? :auto_retry # :nodoc:
386
386
  end
387
387
  @@auto_retry = false
388
388
 
389
- def initialize(config, factory) #:nodoc:
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 #:nodoc:
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! #:nodoc:
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 ] #:nodoc:
426
+ LOST_CONNECTION_ERROR_CODES = [ 28, 1012, 3113, 3114, 3135 ] # :nodoc:
427
427
 
428
428
  # Adds auto-recovery functionality.
429
- def with_retry #:nodoc:
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) #:nodoc:
444
+ def exec(sql, *bindvars, &block) # :nodoc:
445
445
  with_retry { @connection.exec(sql, *bindvars, &block) }
446
446
  end
447
447
  end
448
- #:startdoc:
448
+ # :startdoc:
@@ -4,7 +4,7 @@ module ActiveRecord
4
4
  module ConnectionAdapters
5
5
  module OracleEnhanced
6
6
  module OCIQuoting
7
- def _type_cast(value)
7
+ def type_cast(value)
8
8
  case value
9
9
  when ActiveModel::Type::Binary::Data
10
10
  lob_value = value == "" ? " " : value
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "active_support"
4
4
 
5
- module ActiveRecord #:nodoc:
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 #:nodoc:
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 #:nodoc:
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 partial_writes?
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) { yield }
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)