activerecord-oracle_enhanced-adapter 6.1.6 → 7.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +53 -2
  3. data/README.md +1 -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 +16 -17
  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 +12 -6
  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 +35 -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 +124 -99
  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/timestamp_spec.rb +2 -2
  37. metadata +5 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b17060d198e5da1dcccae49e4c50e114a2fc52c84d7a529271a8c7fc1948c8a4
4
- data.tar.gz: fbc916077b37c9a31f2a3e315b7ddec8559aaaadd5eb4898d67703914586a1e9
3
+ metadata.gz: 06a51471175f7b3fd6cda8a6ca3dc43f6d44f70120c68e9c446b42b953c758d6
4
+ data.tar.gz: 3fdebf8e8d2ba6b4a90cc729f001af1ae15f4fd5a2b9741a6179e958d2e2209a
5
5
  SHA512:
6
- metadata.gz: f1654bf5c9d946e7f795075ae030e8b46560c8f1f680cbe203e953f1d3a596d5f4d20395c56e4bfc0d137cd1adb712f7ceaa50bcedbacae83583f7796d98a6ad
7
- data.tar.gz: cc75b8f1cd8e2abd4ffa8268ba62bba9bbc1fae23d20502226ec95d3c0f56a4a90837e77bf650160b6c5b940db6284608bb191fd7f5b12c0c96eaf07989b75c4
6
+ metadata.gz: eca400fbf518e907f76843e0deda2b6623aa2b16c17fbc9b3c5dfe311ab73e2f082e0a6ea08bd6029dea59ecca64a6eab717caa6a9c44c7cf4783c2c45e24544
7
+ data.tar.gz: 991396d286aea5fe872c0ce3f24f6175b716326011aa1da2ab480176a6fbaa43cc78a43a996c219cc318cb7c8dc4719018d0071be51735a76814b8da5c86e623
data/History.md CHANGED
@@ -1,7 +1,58 @@
1
- ## 6.1.6 / 2022-01-21
1
+ ## 7.0.0.rc1 / 2021-12-08
2
2
 
3
3
  * Changes and bug fixes
4
- * Fix `columns_for_distinct` when using Rails 6.1 [#2249 #2252 rails/rails#31966]
4
+ * Support Rails 7.0.0.rc1
5
+ * Rails 7 requires Ruby 2.7 and prefer Ruby 3+ [#2136]
6
+ * Allow usage of JDBC statement caching by DB config parameter [#2088]
7
+ * structure dump: read column comments from all_tab_cols [#2121]
8
+ * Usage of bind variables for volatile filter conditions (3) [#2125]
9
+ * attribute should not require a connection is established [#2136]
10
+ * Allow Adapter#select_all to be performed asynchronously from a background thread pool [#2146]
11
+ * Avoid extra BindParam allocation to generate placeholder in queries [#2157]
12
+ * Address undefined method `to_i' for #<ActiveModel::Attribute::WithCastValue [#2159]
13
+ * Update Rails default branch name change [#2126]
14
+ * Optimize remove_columns to use a single SQL statement when supported [#2182]
15
+ * Refactor schema creation to extract new_foreign_key_definition [#2183]
16
+ * Address "NoMethodError: undefined method `partial_writes?'" [#2188]
17
+ * Suppress partial_writes deprecation warning [#2189]
18
+ * Make default_timezone a module instance variable [#2190]
19
+ * Define adapter type maps statically when possible [#2199]
20
+ * Rename _type_cast to type_cast [#2199]
21
+ * Rename _quote to quote [#2199]
22
+ * Always use OpenSSL constants for Digest operations [#2217]
23
+ * Refactor ActiveRecord::QueryLogs hook point [#2218]
24
+ * Enable Style/RedundantRegexpEscape cop [#2074]
25
+ * Enable Lint/DuplicateRequire cop [#2107]
26
+ * Enable Layout/SpaceBeforeBrackets cop [#2108]
27
+ * Enable Performance/BindCall cop [#2140]
28
+ * Enable Performance/StringReplacement cop [#2175]
29
+ * Enable Performance/MapCompact cop [#2176]
30
+ * Enable Layout/EndOfLine cop [#2177]
31
+ * Enable Performance/SelectMap cop [#2178]
32
+ * Enable Layout/ClosingParenthesisIndentation cop [#2193]
33
+ * Enable Style/ExplicitBlockArgument cop [#2209]
34
+ * Enable Lint/DuplicateMethods cop [#2215]
35
+ * Disable Lint/ShadowingOuterLocalVariable cop [#2137]
36
+ * Disable Layout/FirstArgumentIndentation cop [#2149]
37
+ * Opt out of SuggestExtensions message [#2133]
38
+ * Suppress RuboCop's offense [#2196]
39
+ * Support RuboCop 1.19.0 [#2204]
40
+ * Prevent from including ojdbc8.jar file to gem file [#2164]
41
+
42
+ * CI
43
+ * Disable CI against JRuby builds [#2136]
44
+ * CI against Ruby 3.0.0 [#2091]
45
+ * CI against Ruby 3.0.1 and 2.7.3 [#2173]
46
+ * CI against Ruby 3.0.2 and 2.7.4 [#2195]
47
+ * Exclude ruby-head and ruby-debug until minitest allows Ruby 3.1 [#2094]
48
+ * Address Travis CI warnings and bump Ubuntu version to 20.04 [#2086]
49
+ * Tidy up Travis CI configuration [#2116]
50
+ * Tweak representation of build matrix [#2129]
51
+ * Install Oracle JDBC driver ojdbc11.jar for GitHub Actions [#2172]
52
+ * Address guides/bug_report_templates/active_record_gem_spec.rb error [#2101]
53
+ * Use Oracle Instant Client 21.1.0.0.0 [#2205]
54
+ * Use Oracle Instant Client 21.4 [#2199]
55
+ * Use gvenzl/oracle-xe docker image [#2206]
5
56
 
6
57
  ## 6.1.5 / 2021-12-07
7
58
 
data/README.md CHANGED
@@ -6,7 +6,7 @@ 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 6.1 and it is working with Oracle database versions 10g and higher
10
10
 
11
11
  INSTALLATION
12
12
  ------------
data/VERSION CHANGED
@@ -1 +1 @@
1
- 6.1.6
1
+ 7.0.0.rc1
@@ -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,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) #: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]
@@ -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?
@@ -52,7 +52,7 @@ 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)