activerecord-oracle_enhanced-adapter 1.7.11 → 1.8.2

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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +206 -4
  3. data/README.md +37 -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 +7 -59
  7. data/lib/active_record/connection_adapters/oracle_enhanced/column_dumper.rb +6 -50
  8. data/lib/active_record/connection_adapters/oracle_enhanced/connection.rb +11 -11
  9. data/lib/active_record/connection_adapters/oracle_enhanced/context_index.rb +117 -117
  10. data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +37 -27
  11. data/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb +10 -10
  12. data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +56 -71
  13. data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb +0 -7
  14. data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +51 -69
  15. data/lib/active_record/connection_adapters/oracle_enhanced/oci_quoting.rb +4 -4
  16. data/lib/active_record/connection_adapters/oracle_enhanced/procedures.rb +76 -76
  17. data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +14 -43
  18. data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +60 -64
  19. data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +33 -47
  20. data/lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb +150 -160
  21. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +95 -133
  22. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements_ext.rb +3 -3
  23. data/lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb +66 -101
  24. data/lib/active_record/connection_adapters/oracle_enhanced/version.rb +1 -1
  25. data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +290 -533
  26. data/lib/active_record/oracle_enhanced/type/boolean.rb +7 -10
  27. data/lib/active_record/oracle_enhanced/type/integer.rb +3 -4
  28. data/lib/active_record/oracle_enhanced/type/json.rb +8 -0
  29. data/lib/active_record/oracle_enhanced/type/national_character_string.rb +1 -1
  30. data/lib/active_record/oracle_enhanced/type/raw.rb +2 -3
  31. data/lib/active_record/oracle_enhanced/type/string.rb +2 -2
  32. data/lib/active_record/oracle_enhanced/type/text.rb +2 -2
  33. data/lib/active_record/oracle_enhanced/type/timestamptz.rb +23 -0
  34. data/lib/activerecord-oracle_enhanced-adapter.rb +2 -2
  35. data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +55 -162
  36. data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +32 -34
  37. data/spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb +44 -42
  38. data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +250 -357
  39. data/spec/active_record/connection_adapters/oracle_enhanced_database_tasks_spec.rb +14 -6
  40. data/spec/active_record/connection_adapters/oracle_enhanced_dbms_output_spec.rb +3 -5
  41. data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +115 -124
  42. data/spec/active_record/connection_adapters/oracle_enhanced_emulate_oracle_adapter_spec.rb +2 -3
  43. data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +68 -72
  44. data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +64 -80
  45. data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +223 -329
  46. data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +18 -20
  47. data/spec/spec_config.yaml.template +11 -0
  48. data/spec/spec_helper.rb +59 -59
  49. data/spec/support/alter_system_user_password.sql +2 -0
  50. data/spec/support/create_oracle_enhanced_users.sql +31 -0
  51. metadata +25 -25
  52. data/.rspec +0 -2
  53. data/Gemfile +0 -22
  54. data/RUNNING_TESTS.md +0 -83
  55. data/Rakefile +0 -45
  56. data/activerecord-oracle_enhanced-adapter.gemspec +0 -94
  57. data/lib/active_record/connection_adapters/oracle_enhanced/cpk.rb +0 -19
  58. data/spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb +0 -113
@@ -2,27 +2,26 @@ begin
2
2
  require "java"
3
3
  require "jruby"
4
4
 
5
- # ojdbc7.jar, ojdbc6.jar or ojdbc5.jar file should be in application ./lib directory or in load path or in ENV['PATH']
5
+ # ojdbc7.jar or ojdbc6.jar file should be in application ./lib directory or in load path or in ENV['PATH']
6
6
 
7
7
  java_version = java.lang.System.getProperty("java.version")
8
- ojdbc_jars = if java_version =~ /^1.5/
9
- %w(ojdbc5.jar)
10
- elsif java_version =~ /^1.6/
11
- %w(ojdbc6.jar)
12
- elsif java_version >= '1.7'
13
- # Oracle 11g client ojdbc6.jar is also compatible with Java 1.7
14
- # Oracle 12c client provides new ojdbc7.jar
15
- %w(ojdbc7.jar ojdbc6.jar)
16
- else
17
- nil
8
+ # Dropping Java SE 6(1.6) or older version without deprecation cycle.
9
+ # Rails 5.0 already requires CRuby 2.2.2 or higher and JRuby 9.0 supporging CRuby 2.2 requires Java SE 7.
10
+ if java_version < "1.7"
11
+ raise "ERROR: Java SE 6 or older version is not supported. Upgrade Java version to Java SE 7 or higher"
18
12
  end
19
13
 
20
- if ojdbc_jars && ENV_JAVA['java.class.path'] !~ Regexp.new(ojdbc_jars.join('|'))
14
+ # Oracle 11g client ojdbc6.jar is also compatible with Java 1.7
15
+ # Oracle 12c Release 1 client provides ojdbc7.jar
16
+ # Oracle 12c Release 2 client provides ojdbc8.jar
17
+ ojdbc_jars = %w(ojdbc8.jar ojdbc7.jar ojdbc6.jar)
18
+
19
+ if ENV_JAVA["java.class.path"] !~ Regexp.new(ojdbc_jars.join("|"))
21
20
  # On Unix environment variable should be PATH, on Windows it is sometimes Path
22
- env_path = (ENV["PATH"] || ENV["Path"] || '').split(File::PATH_SEPARATOR)
21
+ env_path = (ENV["PATH"] || ENV["Path"] || "").split(File::PATH_SEPARATOR)
23
22
  # Look for JDBC driver at first in lib subdirectory (application specific JDBC file version)
24
23
  # then in Ruby load path and finally in environment PATH
25
- ['./lib'].concat($LOAD_PATH).concat(env_path).detect do |dir|
24
+ ["./lib"].concat($LOAD_PATH).concat(env_path).detect do |dir|
26
25
  # check any compatible JDBC driver in the priority order
27
26
  ojdbc_jars.any? do |ojdbc_jar|
28
27
  if File.exists?(file_path = File.join(dir, ojdbc_jar))
@@ -43,7 +42,7 @@ begin
43
42
 
44
43
  rescue LoadError, NameError
45
44
  # JDBC driver is unavailable.
46
- raise LoadError, "ERROR: ActiveRecord oracle_enhanced adapter could not load Oracle JDBC driver. Please install #{ojdbc_jars ? ojdbc_jars.join(' or ') : "Oracle JDBC"} library."
45
+ raise LoadError, "ERROR: ActiveRecord oracle_enhanced adapter could not load Oracle JDBC driver. Please install #{ojdbc_jars.join(' or ') } library."
47
46
  end
48
47
 
49
48
  module ActiveRecord
@@ -74,7 +73,7 @@ module ActiveRecord
74
73
 
75
74
  # tomcat needs first lookup method, oc4j (and maybe other application servers) need second method
76
75
  begin
77
- env = ctx.lookup('java:/comp/env')
76
+ env = ctx.lookup("java:/comp/env")
78
77
  ds = env.lookup(jndi)
79
78
  rescue
80
79
  ds = ctx.lookup(jndi)
@@ -102,13 +101,13 @@ module ActiveRecord
102
101
  # to_s needed if username, password or database is specified as number in database.yml file
103
102
  username = config[:username] && config[:username].to_s
104
103
  password = config[:password] && config[:password].to_s
105
- database = config[:database] && config[:database].to_s || 'XE'
104
+ database = config[:database] && config[:database].to_s || "XE"
106
105
  host, port = config[:host], config[:port]
107
106
  privilege = config[:privilege] && config[:privilege].to_s
108
107
 
109
108
  # connection using TNS alias, or connection-string from DATABASE_URL
110
- using_tns_alias = !host && !config[:url] && ENV['TNS_ADMIN']
111
- if database && (using_tns_alias || host == 'connection-string')
109
+ using_tns_alias = !host && !config[:url] && ENV["TNS_ADMIN"]
110
+ if database && (using_tns_alias || host == "connection-string")
112
111
  url = "jdbc:oracle:thin:@#{database}"
113
112
  else
114
113
  unless database.match(/^(\:|\/)/)
@@ -120,7 +119,7 @@ module ActiveRecord
120
119
 
121
120
  prefetch_rows = config[:prefetch_rows] || 100
122
121
  # get session time_zone from configuration or from TZ environment variable
123
- time_zone = config[:time_zone] || ENV['TZ'] || java.util.TimeZone.default.getID
122
+ time_zone = config[:time_zone] || ENV["TZ"] || java.util.TimeZone.default.getID
124
123
 
125
124
  properties = java.util.Properties.new
126
125
  properties.put("user", username)
@@ -138,13 +137,17 @@ module ActiveRecord
138
137
  end
139
138
 
140
139
  # Set session time zone to current time zone
141
- @raw_connection.setSessionTimeZone(time_zone)
140
+ if ActiveRecord::Base.default_timezone == :local
141
+ @raw_connection.setSessionTimeZone(time_zone)
142
+ elsif ActiveRecord::Base.default_timezone == :utc
143
+ @raw_connection.setSessionTimeZone("UTC")
144
+ end
142
145
 
143
146
  # Set default number of rows to prefetch
144
147
  # @raw_connection.setDefaultRowPrefetch(prefetch_rows) if prefetch_rows
145
148
  end
146
149
 
147
- cursor_sharing = config[:cursor_sharing] || 'force'
150
+ cursor_sharing = config[:cursor_sharing] || "force"
148
151
  exec "alter session set cursor_sharing = #{cursor_sharing}"
149
152
 
150
153
  # Initialize NLS parameters
@@ -327,7 +330,7 @@ module ActiveRecord
327
330
  @raw_statement = raw_statement
328
331
  end
329
332
 
330
- def bind_params( *bind_vars )
333
+ def bind_params(*bind_vars)
331
334
  index = 1
332
335
  bind_vars.flatten.each do |var|
333
336
  if Hash === var
@@ -339,17 +342,7 @@ module ActiveRecord
339
342
  end
340
343
  end
341
344
 
342
- def bind_param(position, value, column = nil)
343
- if column
344
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
345
- *******************************************************
346
- Passing a column to `bind_param` will be deprecated.
347
- `type_casted_binds` should be already type casted
348
- so that `bind_param` should not need to know column.
349
- *******************************************************
350
- MSG
351
- end
352
-
345
+ def bind_param(position, value)
353
346
  case value
354
347
  when Integer
355
348
  @raw_statement.setLong(position, value)
@@ -373,17 +366,13 @@ module ActiveRecord
373
366
  when Java::JavaSql::Timestamp
374
367
  @raw_statement.setTimestamp(position, value)
375
368
  when Time
376
- # TODO: Really needed or not
377
- @raw_statement.setTimestamp(position, value)
369
+ new_value = Java::java.sql.Timestamp.new(value.year - 1900, value.month - 1, value.day, value.hour, value.min, value.sec, value.usec * 1000)
370
+ @raw_statement.setTimestamp(position, new_value)
378
371
  when NilClass
379
- if column && column.object_type?
380
- @raw_statement.setNull(position, java.sql.Types::STRUCT, column.sql_type)
381
- else
382
- # TODO: currently nil is always bound as NULL with VARCHAR type.
383
- # When nils will actually be used by ActiveRecord as bound parameters
384
- # then need to pass actual column type.
385
- @raw_statement.setNull(position, java.sql.Types::VARCHAR)
386
- end
372
+ # TODO: currently nil is always bound as NULL with VARCHAR type.
373
+ # When nils will actually be used by ActiveRecord as bound parameters
374
+ # then need to pass actual column type.
375
+ @raw_statement.setNull(position, java.sql.Types::VARCHAR)
387
376
  else
388
377
  raise ArgumentError, "Don't know how to bind variable with type #{value.class}"
389
378
  end
@@ -411,21 +400,21 @@ module ActiveRecord
411
400
  end
412
401
 
413
402
  def column_types
414
- @column_types ||= (1..metadata.getColumnCount).map{|i| metadata.getColumnTypeName(i).to_sym}
403
+ @column_types ||= (1..metadata.getColumnCount).map { |i| metadata.getColumnTypeName(i).to_sym }
415
404
  end
416
405
 
417
406
  def column_names
418
- @column_names ||= (1..metadata.getColumnCount).map{|i| metadata.getColumnName(i)}
407
+ @column_names ||= (1..metadata.getColumnCount).map { |i| metadata.getColumnName(i) }
419
408
  end
420
409
  alias :get_col_names :column_names
421
410
 
422
- def fetch(options={})
411
+ def fetch(options = {})
423
412
  if @raw_result_set.next
424
413
  get_lob_value = options[:get_lob_value]
425
414
  row_values = []
426
415
  column_types.each_with_index do |column_type, i|
427
416
  row_values <<
428
- @connection.get_ruby_value_from_result_set(@raw_result_set, i+1, column_type, get_lob_value)
417
+ @connection.get_ruby_value_from_result_set(@raw_result_set, i + 1, column_type, get_lob_value)
429
418
  end
430
419
  row_values
431
420
  else
@@ -469,14 +458,14 @@ module ActiveRecord
469
458
 
470
459
  cols_types_index = (1..column_count).map do |i|
471
460
  col_name = oracle_downcase(metadata.getColumnName(i))
472
- next if col_name == 'raw_rnum_'
461
+ next if col_name == "raw_rnum_"
473
462
  column_hash[col_name] = nil
474
463
  [col_name, metadata.getColumnTypeName(i).to_sym, i]
475
464
  end
476
465
  cols_types_index.delete(nil)
477
466
 
478
467
  rows = []
479
- get_lob_value = !(name == 'Writable Large Object')
468
+ get_lob_value = !(name == "Writable Large Object")
480
469
 
481
470
  while rset.next
482
471
  hash = column_hash.dup
@@ -496,7 +485,7 @@ module ActiveRecord
496
485
  if is_binary
497
486
  lob.setBytes(1, value.to_java_bytes)
498
487
  else
499
- lob.setString(1,value)
488
+ lob.setString(1, value)
500
489
  end
501
490
  end
502
491
 
@@ -529,11 +518,7 @@ module ActiveRecord
529
518
  if dt = rset.getDATE(i)
530
519
  d = dt.dateValue
531
520
  t = dt.timeValue
532
- if OracleEnhancedAdapter.emulate_dates && t.hours == 0 && t.minutes == 0 && t.seconds == 0
533
- Date.new(d.year + 1900, d.month + 1, d.date)
534
- else
535
- Time.send(Base.default_timezone, d.year + 1900, d.month + 1, d.date, t.hours, t.minutes, t.seconds)
536
- end
521
+ Time.send(Base.default_timezone, d.year + 1900, d.month + 1, d.date, t.hours, t.minutes, t.seconds)
537
522
  else
538
523
  nil
539
524
  end
@@ -547,7 +532,7 @@ module ActiveRecord
547
532
  get_lob_value ? lob_to_ruby_value(rset.getBlob(i)) : rset.getBlob(i)
548
533
  when :RAW
549
534
  raw_value = rset.getRAW(i)
550
- raw_value && raw_value.getBytes.to_a.pack('C*')
535
+ raw_value && raw_value.getBytes.to_a.pack("C*")
551
536
  else
552
537
  nil
553
538
  end
@@ -555,22 +540,22 @@ module ActiveRecord
555
540
 
556
541
  private
557
542
 
558
- def lob_to_ruby_value(val)
559
- case val
560
- when ::Java::OracleSql::CLOB
561
- if val.isEmptyLob
562
- nil
563
- else
564
- val.getSubString(1, val.length)
565
- end
566
- when ::Java::OracleSql::BLOB
567
- if val.isEmptyLob
568
- nil
569
- else
570
- String.from_java_bytes(val.getBytes(1, val.length))
543
+ def lob_to_ruby_value(val)
544
+ case val
545
+ when ::Java::OracleSql::CLOB
546
+ if val.isEmptyLob
547
+ nil
548
+ else
549
+ val.getSubString(1, val.length)
550
+ end
551
+ when ::Java::OracleSql::BLOB
552
+ if val.isEmptyLob
553
+ nil
554
+ else
555
+ String.from_java_bytes(val.getBytes(1, val.length))
556
+ end
571
557
  end
572
558
  end
573
- end
574
559
  end
575
560
  end
576
561
  end
@@ -12,13 +12,6 @@ module ActiveRecord
12
12
  clob = Java::OracleSql::CLOB.createTemporary(@connection.raw_connection, false, Java::OracleSql::CLOB::DURATION_SESSION)
13
13
  clob.setString(1, value.to_s)
14
14
  clob
15
- when Date, DateTime
16
- Java::oracle.sql.DATE.new(value.strftime("%Y-%m-%d %H:%M:%S"))
17
- when Time
18
- Java::java.sql.Timestamp.new(value.year-1900, value.month-1, value.day, value.hour, value.min, value.sec, value.usec * 1000)
19
- when Java::JavaSql::Timestamp
20
- # Returning value as it is likely this value was already type casted from Time to Java::JavaSql::Timestamp
21
- value
22
15
  else
23
16
  super
24
17
  end
@@ -1,4 +1,4 @@
1
- require 'delegate'
1
+ require "delegate"
2
2
 
3
3
  begin
4
4
  require "oci8"
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  # check ruby-oci8 version
13
13
  required_oci8_version = [2, 2, 0]
14
- oci8_version_ints = OCI8::VERSION.scan(/\d+/).map{|s| s.to_i}
14
+ oci8_version_ints = OCI8::VERSION.scan(/\d+/).map { |s| s.to_i }
15
15
  if (oci8_version_ints <=> required_oci8_version) < 0
16
16
  raise LoadError, "ERROR: ruby-oci8 version #{OCI8::VERSION} is too old. Please install ruby-oci8 version #{required_oci8_version.join('.')} or later."
17
17
  end
@@ -98,9 +98,9 @@ module ActiveRecord
98
98
  # and return :insert_id value
99
99
  def exec_with_returning(sql)
100
100
  cursor = @raw_connection.parse(sql)
101
- cursor.bind_param(':insert_id', nil, Integer)
101
+ cursor.bind_param(":insert_id", nil, Integer)
102
102
  cursor.exec
103
- cursor[':insert_id']
103
+ cursor[":insert_id"]
104
104
  ensure
105
105
  cursor.close rescue nil
106
106
  end
@@ -115,7 +115,7 @@ module ActiveRecord
115
115
  @raw_cursor = raw_cursor
116
116
  end
117
117
 
118
- def bind_params( *bind_vars )
118
+ def bind_params(*bind_vars)
119
119
  index = 1
120
120
  bind_vars.flatten.each do |var|
121
121
  if Hash === var
@@ -127,30 +127,16 @@ module ActiveRecord
127
127
  end
128
128
  end
129
129
 
130
- def bind_param(position, value, column = nil)
131
- if column
132
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
133
- *******************************************************
134
- Passing a column to `bind_param` will be deprecated.
135
- `type_casted_binds` should be already type casted
136
- so that `bind_param` should not need to know column.
137
- *******************************************************
138
- MSG
139
- end
140
-
141
- if column && column.object_type?
142
- @raw_cursor.bind_param(position, value, :named_type, column.sql_type)
130
+ def bind_param(position, value)
131
+ case value
132
+ when ActiveRecord::OracleEnhanced::Type::Raw
133
+ @raw_cursor.bind_param(position, ActiveRecord::ConnectionAdapters::OracleEnhanced::Quoting.encode_raw(value))
134
+ when ActiveModel::Type::Decimal
135
+ @raw_cursor.bind_param(position, BigDecimal.new(value.to_s))
136
+ when NilClass
137
+ @raw_cursor.bind_param(position, nil, String)
143
138
  else
144
- case value
145
- when ActiveRecord::OracleEnhanced::Type::Raw
146
- @raw_cursor.bind_param(position, ActiveRecord::ConnectionAdapters::OracleEnhanced::Quoting.encode_raw(value))
147
- when ActiveModel::Type::Decimal
148
- @raw_cursor.bind_param(position, BigDecimal.new(value.to_s))
149
- when NilClass
150
- @raw_cursor.bind_param(position, nil, String)
151
- else
152
- @raw_cursor.bind_param(position, value)
153
- end
139
+ @raw_cursor.bind_param(position, value)
154
140
  end
155
141
  end
156
142
 
@@ -170,7 +156,7 @@ module ActiveRecord
170
156
  @raw_cursor.get_col_names
171
157
  end
172
158
 
173
- def fetch(options={})
159
+ def fetch(options = {})
174
160
  if row = @raw_cursor.fetch
175
161
  get_lob_value = options[:get_lob_value]
176
162
  row.map do |col|
@@ -194,13 +180,13 @@ module ActiveRecord
194
180
  # Ignore raw_rnum_ which is used to simulate LIMIT and OFFSET
195
181
  cursor.get_col_names.each do |col_name|
196
182
  col_name = oracle_downcase(col_name)
197
- cols << col_name unless col_name == 'raw_rnum_'
183
+ cols << col_name unless col_name == "raw_rnum_"
198
184
  end
199
185
  # Reuse the same hash for all rows
200
186
  column_hash = {}
201
- cols.each {|c| column_hash[c] = nil}
187
+ cols.each { |c| column_hash[c] = nil }
202
188
  rows = []
203
- get_lob_value = !(name == 'Writable Large Object')
189
+ get_lob_value = !(name == "Writable Large Object")
204
190
 
205
191
  while row = cursor.fetch
206
192
  hash = column_hash.dup
@@ -223,7 +209,7 @@ module ActiveRecord
223
209
 
224
210
  def describe(name)
225
211
  # fall back to SELECT based describe if using database link
226
- return super if name.to_s.include?('@')
212
+ return super if name.to_s.include?("@")
227
213
  quoted_name = ActiveRecord::ConnectionAdapters::OracleEnhanced::Quoting.valid_table_name?(name) ? name : "\"#{name}\""
228
214
  @raw_connection.describe(quoted_name)
229
215
  rescue OCIException => e
@@ -261,17 +247,13 @@ module ActiveRecord
261
247
  if get_lob_value
262
248
  data = value.read || "" # if value.read returns nil, then we have an empty_clob() i.e. an empty string
263
249
  # In Ruby 1.9.1 always change encoding to ASCII-8BIT for binaries
264
- data.force_encoding('ASCII-8BIT') if data.respond_to?(:force_encoding) && value.is_a?(OCI8::BLOB)
250
+ data.force_encoding("ASCII-8BIT") if data.respond_to?(:force_encoding) && value.is_a?(OCI8::BLOB)
265
251
  data
266
252
  else
267
253
  value
268
254
  end
269
255
  when Time, DateTime
270
- if OracleEnhancedAdapter.emulate_dates && date_without_time?(value)
271
- value.to_date
272
- else
273
- create_time_with_default_timezone(value)
274
- end
256
+ create_time_with_default_timezone(value)
275
257
  else
276
258
  value
277
259
  end
@@ -283,32 +265,32 @@ module ActiveRecord
283
265
 
284
266
  private
285
267
 
286
- def date_without_time?(value)
287
- case value
288
- when OraDate
289
- value.hour == 0 && value.minute == 0 && value.second == 0
290
- else
291
- value.hour == 0 && value.min == 0 && value.sec == 0
268
+ def date_without_time?(value)
269
+ case value
270
+ when OraDate
271
+ value.hour == 0 && value.minute == 0 && value.second == 0
272
+ else
273
+ value.hour == 0 && value.min == 0 && value.sec == 0
274
+ end
292
275
  end
293
- end
294
276
 
295
- def create_time_with_default_timezone(value)
296
- year, month, day, hour, min, sec, usec = case value
297
- when Time
298
- [value.year, value.month, value.day, value.hour, value.min, value.sec, value.usec]
299
- when OraDate
300
- [value.year, value.month, value.day, value.hour, value.minute, value.second, 0]
301
- else
302
- [value.year, value.month, value.day, value.hour, value.min, value.sec, 0]
303
- end
304
- # code from Time.time_with_datetime_fallback
305
- begin
306
- Time.send(Base.default_timezone, year, month, day, hour, min, sec, usec)
307
- rescue
308
- offset = Base.default_timezone.to_sym == :local ? ::DateTime.local_offset : 0
309
- ::DateTime.civil(year, month, day, hour, min, sec, offset)
277
+ def create_time_with_default_timezone(value)
278
+ year, month, day, hour, min, sec, usec = case value
279
+ when Time
280
+ [value.year, value.month, value.day, value.hour, value.min, value.sec, value.usec]
281
+ when OraDate
282
+ [value.year, value.month, value.day, value.hour, value.minute, value.second, 0]
283
+ else
284
+ [value.year, value.month, value.day, value.hour, value.min, value.sec, 0]
285
+ end
286
+ # code from Time.time_with_datetime_fallback
287
+ begin
288
+ Time.send(Base.default_timezone, year, month, day, hour, min, sec, usec)
289
+ rescue
290
+ offset = Base.default_timezone.to_sym == :local ? ::DateTime.local_offset : 0
291
+ ::DateTime.civil(year, month, day, hour, min, sec, offset)
292
+ end
310
293
  end
311
- end
312
294
  end
313
295
 
314
296
  # The OracleEnhancedOCIFactory factors out the code necessary to connect and
@@ -324,16 +306,16 @@ module ActiveRecord
324
306
  privilege = config[:privilege] && config[:privilege].to_sym
325
307
  async = config[:allow_concurrency]
326
308
  prefetch_rows = config[:prefetch_rows] || 100
327
- cursor_sharing = config[:cursor_sharing] || 'force'
309
+ cursor_sharing = config[:cursor_sharing] || "force"
328
310
  # get session time_zone from configuration or from TZ environment variable
329
- time_zone = config[:time_zone] || ENV['TZ']
311
+ time_zone = config[:time_zone] || ENV["TZ"]
330
312
 
331
313
  # using a connection string via DATABASE_URL
332
- connection_string = if host == 'connection-string'
314
+ connection_string = if host == "connection-string"
333
315
  database
334
316
  # connection using host, port and database name
335
317
  elsif host || port
336
- host ||= 'localhost'
318
+ host ||= "localhost"
337
319
  host = "[#{host}]" if host =~ /^[^\[].*:/ # IPv6
338
320
  port ||= 1521
339
321
  database = "/#{database}" unless database.match(/^\//)
@@ -372,8 +354,8 @@ class OCI8 #:nodoc:
372
354
  def describe(name)
373
355
  info = describe_table(name.to_s)
374
356
  raise %Q{"DESC #{name}" failed} if info.nil?
375
- if info.respond_to? :obj_link and info.obj_link
376
- [info.obj_schema, info.obj_name, '@' + info.obj_link]
357
+ if info.respond_to?(:obj_link) && info.obj_link
358
+ [info.obj_schema, info.obj_name, "@" + info.obj_link]
377
359
  else
378
360
  [info.obj_schema, info.obj_name]
379
361
  end
@@ -402,7 +384,7 @@ class OCI8EnhancedAutoRecover < DelegateClass(OCI8) #:nodoc:
402
384
  @active = true
403
385
  @config = config
404
386
  @factory = factory
405
- @connection = @factory.new_connection @config
387
+ @connection = @factory.new_connection @config
406
388
  super @connection
407
389
  end
408
390
 
@@ -5,16 +5,16 @@ module ActiveRecord
5
5
  def _type_cast(value)
6
6
  case value
7
7
  when ActiveModel::Type::Binary::Data
8
- lob_value = value == '' ? ' ' : value
8
+ lob_value = value == "" ? " " : value
9
9
  bind_type = OCI8::BLOB
10
10
  ora_value = bind_type.new(@connection.raw_oci_connection, lob_value)
11
- ora_value.size = 0 if value == ''
11
+ ora_value.size = 0 if value == ""
12
12
  ora_value
13
13
  when ActiveRecord::OracleEnhanced::Type::Text::Data
14
- lob_value = value.to_s == '' ? ' ' : value.to_s
14
+ lob_value = value.to_s == "" ? " " : value.to_s
15
15
  bind_type = OCI8::CLOB
16
16
  ora_value = bind_type.new(@connection.raw_oci_connection, lob_value)
17
- ora_value.size = 0 if value.to_s == ''
17
+ ora_value.size = 0 if value.to_s == ""
18
18
  ora_value
19
19
  else
20
20
  super