activerecord-oracle_enhanced-adapter 6.0.0.rc2 → 6.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bdc31c880510cdf6b84f68c710f76cbc32d8819c2509daa0932abb7b5bc61953
4
- data.tar.gz: 7b9a581e8f9aad1e49e1d27c1295d36a721d0fef816a6eb30a6a02e60c9c89f8
3
+ metadata.gz: ecb6a81d928e0b751feb92c6eddbf1f11ae67ff269430216611f0d8871a3de7f
4
+ data.tar.gz: 345cfa5a563fdb93d59404b13177bdf39f837f3d3338956b5b242ba85d95cca0
5
5
  SHA512:
6
- metadata.gz: e346ff86f05d843165df5c5b505568a78a6e2fe0b8291cde8cb8608913bc7a8c1a68ca5304d129da9ba51a0781a0d26fc075183283697566023aa0eabb3ee7c5
7
- data.tar.gz: a63ee6a2411af0f9743beee488f553318609a8ab19549a8ed54fdc494fda931c01e2bf4a74a293ad2fbda40a7551f7a9c693f504f95e7f9aec77a5a93fbe0b1d
6
+ metadata.gz: 44789c82df86d977714f00ef4a90b08c2d554c9e9b0cd3e2f39854ed89e69c02ade149990d1c16fe0630e91f0b13960e5263340d430e182f05791cabbb82d515
7
+ data.tar.gz: c1dad68beacf2a519ab0819b41c3249902f64b6ba61c440aa0cc8f566d0e9820e12a4f45d2dd52e733a076c267016cf9fa895f7774f8b36c19c756b375f55a6b
data/History.md CHANGED
@@ -1,3 +1,60 @@
1
+ ## 6.0.4 / 2020-08-18
2
+
3
+ * Changes and bug fixes
4
+ * create_table_definition and add_column take keyword arguments [#1942, #2043]
5
+ * Fix keyword arguments errors for Ruby 2.8.0-dev [#1977,#2043]
6
+ * Fix a build errors when using Ruby 2.8.0-dev [#1983, #2043]
7
+
8
+ ## 6.0.3 / 2020-06-16
9
+
10
+ * Changes and bug fixes
11
+ * Auto retry works for other `exec_*` methods [#1976, #1981]
12
+ * Allow column name with function (e.g. `length(title)`) as safe SQL string [#2017, #2018]
13
+
14
+ * CI
15
+ * CI against latest Ruby versions [#1979]
16
+
17
+ ## 6.0.2 / 2019-12-25
18
+
19
+ * Changes and bug fixes
20
+ * Uninstall SimpleCov [#1968]
21
+
22
+ ## 6.0.1 / 2019-12-20
23
+
24
+ * Changes and bug fixes
25
+ * Address `undefined local variable or method `sql' [#1932 #1962 #1963]
26
+
27
+ * CI
28
+ * CI against Ruby 2.6.4 and Ruby 2.5.6 [#1922]
29
+
30
+ ## 6.0.0 / 2019-08-17
31
+
32
+ * Major changes, including changes since 6.0.0.beta1
33
+
34
+ * Support Rails 6.0.0
35
+ * Rails 6 requires Ruby 2.5 [#1801]
36
+ * Support longer identifier for Oracle database 12.2 or higher [#1703 #1705]
37
+ * Introduce `use_shorter_identifier` [#1707]
38
+ * Change `default_sequence_start_value` from 10000 to 1 [#1636]
39
+ * Address `ORA-01795: maximum number of expressions in a list is 1000`
40
+
41
+ * CI
42
+ * CI against JRuby 9.2.8.0 #1912
43
+
44
+ ## 6.0.0.rc3 / 2019-07-27
45
+
46
+ * Changes and bug fixes
47
+ * Share the column and table name quote cache between connections [#1901 #1903]
48
+
49
+ ## 6.0.0.rc2 / 2019-07-23
50
+
51
+ * Major changes
52
+ * Support Rails 6.0.0 rc2
53
+ * Add TCP keepalive and TCP keepalive time configurations [#1874 #1877]
54
+
55
+ * Changes and bug fixes
56
+ * Update bug report templates for Oracle enhanced adapter 6.0 [#1873]
57
+
1
58
  ## 6.0.0.rc1 / 2019-04-25
2
59
 
3
60
  * Major changes
@@ -82,7 +139,7 @@
82
139
  * Restore old Code Climate behavior [#1716]
83
140
  * Do not install bundler explicitly [#1725]
84
141
 
85
- * RuboCop
142
+ * RuboCop
86
143
 
87
144
  * Add RuboCop to Gemfile [#1841]
88
145
  * Bump RuboCop to 0.63.0 [#1816]
@@ -279,7 +336,7 @@
279
336
  * Remove `add_runtime_dependency` with arel [#1385]
280
337
  * Move methods for synonyms out of `SchemaStatementsExt` [#1387]
281
338
  * Remove incorrect prepend to `ActiveRecord::ColumnDumper` [#1394]
282
- * Handle `ActiveRecord::SchemaDumper` by `adapter_name` [#1395]
339
+ * Handle `ActiveRecord::SchemaDumper` by `adapter_name` [#1395]
283
340
  * Rewrite `remove_prefix_and_suffix` to be similar with super #1401
284
341
  * `remove_prefix_and_suffix` handles dollar sign by `Regexp#escape` [#1402]
285
342
  * `prepare_column_options` is now private [#1429]
@@ -543,7 +600,7 @@
543
600
  * Use the latest arel master while developing alpha version [#1115]
544
601
  * Bump Arel to 8.0 [#1120, #1121, #1124]
545
602
  * Use released Arel 8 [#1205]
546
- * Remove duplicate license information [#965]
603
+ * Remove duplicate license information [#965]
547
604
  * Clean up comments and un-commented specs for table comment feature [#971]
548
605
  * Use Rails migration `create_table` to create table and sequence [#991]
549
606
  * Removed a invalid spec about TIMESTAMP column [#1020]
@@ -931,7 +988,7 @@
931
988
  * Address `add_column_options!': undefined method `quote_value' [#647]
932
989
  * Remove dirty tracking methods [#883]
933
990
  * Use arel master branch for rails5 development [#645]
934
- * Bump ruby-oci8 version to 2.2.0 or higher [#775]
991
+ * Bump ruby-oci8 version to 2.2.0 or higher [#775]
935
992
  * Remove jeweler dependency [#766]
936
993
  * Remove required_rubygems_version [#719]
937
994
  * Remove journey which is already part of Rails [#701]
@@ -969,13 +1026,13 @@
969
1026
  * Rails 5 : create table with primary key trigger with default primary key not returning id [#912]
970
1027
  * Rails 5 : dirty object tracking not working correctly for CLOB [#911]
971
1028
  * Rails 5 : handling of CLOB columns get failures [#910]
972
- * Rails 5 : SQL with bind parameters when NLS_NUMERIC_CHARACTERS is set to ', '
1029
+ * Rails 5 : SQL with bind parameters when NLS_NUMERIC_CHARACTERS is set to ', '
973
1030
  show Java::JavaSql::SQLSyntaxErrorException: / ORA-01722: invalid number [#909]
974
1031
  * Rails 5 : explain should explain query with binds got Java::JavaSql::SQLException: Invalid column index [#908]
975
1032
  - CRuby and JRuby
976
1033
  * Rails 5 : create table with primary key trigger not returning id [#907]
977
1034
  * Rails 5 : custom methods for create, update and destroy not working [#906]
978
- * Rails 5 : has_and_belongs_to_many test gets ORA-01400 since primary key column "ID"
1035
+ * Rails 5 : has_and_belongs_to_many test gets ORA-01400 since primary key column "ID"
979
1036
  not included in insert statement [#856, rails/rails#25388]
980
1037
  * Rails 5 : undefined method `to_i' for #<Arel::Nodes::BindParam:0x00000002c92910> [#848, rails/arel#438]
981
1038
 
@@ -1038,11 +1095,11 @@
1038
1095
 
1039
1096
  * Changes and bug fixes since 1.6.0
1040
1097
 
1041
- * Oracle enhanced adapter v1.6 requires ActiveRecord 4.2.1 or higher,
1098
+ * Oracle enhanced adapter v1.6 requires ActiveRecord 4.2.1 or higher,
1042
1099
  ActiveRecord 4.2.0 is not supported.[#651, #652]
1043
1100
  * Fix serialized value becomes from yaml to string once saved [#655, #657]
1044
1101
  * Update Ruby version in readme [#654]
1045
- * Update unit test matcher to skip sql statements to get `table` metadata [#653]
1102
+ * Update unit test matcher to skip sql statements to get `table` metadata [#653]
1046
1103
 
1047
1104
  ## 1.6.0 / 2015-06-25
1048
1105
 
@@ -1125,7 +1182,7 @@
1125
1182
  * Change log method signiture to support Rails 4.2 [#539]
1126
1183
  * Enable loading spec configuration from config file instead of env [#550]
1127
1184
  * Rails42: Issue with non-existent columns [#545, #551]
1128
- * Squelch warning "#column_for_attribute` will return a null object
1185
+ * Squelch warning "#column_for_attribute` will return a null object
1129
1186
  for non-existent columns in Rails 5. Use `#has_attribute?`" [#551]
1130
1187
  * Use arel 6-0-stable [#565]
1131
1188
  * Support 'Y' as true and 'N' as false in Rails 4.2 [#574, #573]
@@ -1136,7 +1193,7 @@
1136
1193
  * Rails 4.2 Address ArgumentError: wrong number of arguments (1 for 2) at `quote_value` [#511]
1137
1194
  * Address ORA-00932: inconsistent datatypes: expected NUMBER got DATE [#538]
1138
1195
  * Remove duplicate alias_method_chain for indexes [#560]
1139
- * Address RangeError: 6000000000 is out of range for ActiveRecord::Type::Integer
1196
+ * Address RangeError: 6000000000 is out of range for ActiveRecord::Type::Integer
1140
1197
  with limit 4 [#578]
1141
1198
  * Return foreign_keys_without_oracle_enhanced when non Oracle database used [#583]
1142
1199
  * Add missing database_tasks.rb to gemspec [#585]
@@ -1181,7 +1238,7 @@
1181
1238
  * Enhancements
1182
1239
  * Oracle NUMBER datatype can be handled as Rails :float datatype [#418]
1183
1240
  - Default NUMBER datatype handled as :decimal to keep compatibility
1184
- - Configured by setting `self.number_datatype_coercion = :float`
1241
+ - Configured by setting `self.number_datatype_coercion = :float`
1185
1242
  * Add link to supported Oracle database version, JDK and Oracle JDBC Driver version [#438]
1186
1243
  * Support `without_prepared_statements?` to handle `unprepared_statement` [#447]
1187
1244
 
@@ -1263,7 +1320,7 @@
1263
1320
  * Create indexes automatically for references and belongs_to [#183]
1264
1321
  * Use the index name explicitly provided in a migration when reverting [#296]
1265
1322
  * Rename indexes when a table or column is renamed [#286]
1266
- * Support refactored remove_column [#172]
1323
+ * Support refactored remove_column [#172]
1267
1324
  * Support allowed_index_name_length method [#285]
1268
1325
  * Remove schema prefix from sequence name if present before truncating [#155]
1269
1326
  * Bumped jeweler, ruby-plsql and ruby-oci8 version [#176]
@@ -1579,7 +1636,7 @@
1579
1636
  * Added support for NVARCHAR2 column type
1580
1637
  * Bug fixes:
1581
1638
  * Do not call write_lobs callback when custom create or update methods are defined
1582
-
1639
+
1583
1640
  ### 1.1.5 / 2008-07-27
1584
1641
 
1585
1642
  * 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 5.2 and it is working with Oracle database versions from 10g to 12c.
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
10
10
 
11
11
  INSTALLATION
12
12
  ------------
13
+ ### Rails 6.0
14
+
15
+ Oracle enhanced adapter version 6.0 supports Rails 6.0.
16
+ When using Ruby on Rails version 6.0 then in Gemfile include
17
+
18
+ ```ruby
19
+ # Use oracle as the database for Active Record
20
+ gem 'activerecord-oracle_enhanced-adapter', '~> 6.0.0'
21
+ gem 'ruby-oci8' # only for CRuby users
22
+ ```
23
+
13
24
  ### Rails 5.2
14
25
 
15
26
  Oracle enhanced adapter version 5.2 supports Rails 5.2.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 6.0.0.rc2
1
+ 6.0.4
@@ -24,21 +24,23 @@ module ActiveRecord
24
24
  log(sql, name, binds, type_casted_binds) do
25
25
  cursor = nil
26
26
  cached = false
27
- if without_prepared_statement?(binds)
28
- cursor = @connection.prepare(sql)
29
- else
30
- unless @statements.key? sql
31
- @statements[sql] = @connection.prepare(sql)
32
- end
27
+ with_retry do
28
+ if without_prepared_statement?(binds)
29
+ cursor = @connection.prepare(sql)
30
+ else
31
+ unless @statements.key? sql
32
+ @statements[sql] = @connection.prepare(sql)
33
+ end
33
34
 
34
- cursor = @statements[sql]
35
+ cursor = @statements[sql]
35
36
 
36
- cursor.bind_params(type_casted_binds)
37
+ cursor.bind_params(type_casted_binds)
37
38
 
38
- cached = true
39
- end
39
+ cached = true
40
+ end
40
41
 
41
- cursor.exec
42
+ cursor.exec
43
+ end
42
44
 
43
45
  if (name == "EXPLAIN") && sql =~ /^EXPLAIN/
44
46
  res = true
@@ -96,29 +98,32 @@ module ActiveRecord
96
98
 
97
99
  log(sql, name, binds, type_casted_binds) do
98
100
  cached = false
101
+ cursor = nil
99
102
  returning_id_col = returning_id_index = nil
100
- if without_prepared_statement?(binds)
101
- cursor = @connection.prepare(sql)
102
- else
103
- unless @statements.key?(sql)
104
- @statements[sql] = @connection.prepare(sql)
105
- end
103
+ with_retry do
104
+ if without_prepared_statement?(binds)
105
+ cursor = @connection.prepare(sql)
106
+ else
107
+ unless @statements.key?(sql)
108
+ @statements[sql] = @connection.prepare(sql)
109
+ end
110
+
111
+ cursor = @statements[sql]
106
112
 
107
- cursor = @statements[sql]
113
+ cursor.bind_params(type_casted_binds)
108
114
 
109
- cursor.bind_params(type_casted_binds)
115
+ if /:returning_id/.match?(sql)
116
+ # it currently expects that returning_id comes last part of binds
117
+ returning_id_index = binds.size
118
+ cursor.bind_returning_param(returning_id_index, Integer)
119
+ end
110
120
 
111
- if /:returning_id/.match?(sql)
112
- # it currently expects that returning_id comes last part of binds
113
- returning_id_index = binds.size
114
- cursor.bind_returning_param(returning_id_index, Integer)
121
+ cached = true
115
122
  end
116
123
 
117
- cached = true
124
+ cursor.exec_update
118
125
  end
119
126
 
120
- cursor.exec_update
121
-
122
127
  rows = []
123
128
  if returning_id_index
124
129
  returning_id = cursor.get_returning_param(returning_id_index, Integer).to_i
@@ -134,24 +139,26 @@ module ActiveRecord
134
139
  type_casted_binds = type_casted_binds(binds)
135
140
 
136
141
  log(sql, name, binds, type_casted_binds) do
137
- cached = false
138
- if without_prepared_statement?(binds)
139
- cursor = @connection.prepare(sql)
140
- else
141
- if @statements.key?(sql)
142
- cursor = @statements[sql]
142
+ with_retry do
143
+ cached = false
144
+ if without_prepared_statement?(binds)
145
+ cursor = @connection.prepare(sql)
143
146
  else
144
- cursor = @statements[sql] = @connection.prepare(sql)
145
- end
147
+ if @statements.key?(sql)
148
+ cursor = @statements[sql]
149
+ else
150
+ cursor = @statements[sql] = @connection.prepare(sql)
151
+ end
146
152
 
147
- cursor.bind_params(type_casted_binds)
153
+ cursor.bind_params(type_casted_binds)
148
154
 
149
- cached = true
150
- end
155
+ cached = true
156
+ end
151
157
 
152
- res = cursor.exec_update
153
- cursor.close unless cached
154
- res
158
+ res = cursor.exec_update
159
+ cursor.close unless cached
160
+ res
161
+ end
155
162
  end
156
163
  end
157
164
 
@@ -252,7 +259,7 @@ module ActiveRecord
252
259
  value = klass.attribute_types[col.name].serialize(value)
253
260
  end
254
261
  uncached do
255
- unless lob_record = select_one(<<~SQL.squish, "Writable Large Object")
262
+ unless lob_record = select_one(sql = <<~SQL.squish, "Writable Large Object")
256
263
  SELECT #{quote_column_name(col.name)} FROM #{quote_table_name(table_name)}
257
264
  WHERE #{quote_column_name(klass.primary_key)} = #{id} FOR UPDATE
258
265
  SQL
@@ -263,6 +270,16 @@ module ActiveRecord
263
270
  end
264
271
  end
265
272
  end
273
+
274
+ private
275
+ def with_retry
276
+ @connection.with_retry do
277
+ yield
278
+ rescue
279
+ @statements.clear
280
+ raise
281
+ end
282
+ end
266
283
  end
267
284
  end
268
285
  end
@@ -97,6 +97,10 @@ module ActiveRecord
97
97
  @raw_connection.exec(sql, *bindvars, &block)
98
98
  end
99
99
 
100
+ def with_retry(&block)
101
+ @raw_connection.with_retry(&block)
102
+ end
103
+
100
104
  def prepare(sql)
101
105
  Cursor.new(self, @raw_connection.parse(sql))
102
106
  end
@@ -423,13 +427,11 @@ class OCI8EnhancedAutoRecover < DelegateClass(OCI8) #:nodoc:
423
427
  LOST_CONNECTION_ERROR_CODES = [ 28, 1012, 3113, 3114, 3135 ] #:nodoc:
424
428
 
425
429
  # Adds auto-recovery functionality.
426
- #
427
- # See: http://www.jiubao.org/ruby-oci8/api.en.html#label-11
428
- def exec(sql, *bindvars, &block) #:nodoc:
430
+ def with_retry #:nodoc:
429
431
  should_retry = self.class.auto_retry? && autocommit?
430
432
 
431
433
  begin
432
- @connection.exec(sql, *bindvars, &block)
434
+ yield
433
435
  rescue OCIException => e
434
436
  raise unless e.is_a?(OCIError) && LOST_CONNECTION_ERROR_CODES.include?(e.code)
435
437
  @active = false
@@ -439,5 +441,9 @@ class OCI8EnhancedAutoRecover < DelegateClass(OCI8) #:nodoc:
439
441
  retry
440
442
  end
441
443
  end
444
+
445
+ def exec(sql, *bindvars, &block) #:nodoc:
446
+ with_retry { @connection.exec(sql, *bindvars, &block) }
447
+ end
442
448
  end
443
449
  #:startdoc:
@@ -10,7 +10,7 @@ module ActiveRecord
10
10
 
11
11
  def quote_column_name(name) #:nodoc:
12
12
  name = name.to_s
13
- @quoted_column_names[name] ||= begin
13
+ self.class.quoted_column_names[name] ||= begin
14
14
  # if only valid lowercase column characters in name
15
15
  if /\A[a-z][a-z_0-9\$#]*\Z/.match?(name)
16
16
  "\"#{name.upcase}\""
@@ -70,7 +70,7 @@ module ActiveRecord
70
70
 
71
71
  def quote_table_name(name) #:nodoc:
72
72
  name, _link = name.to_s.split("@")
73
- @quoted_table_names[name] ||= [name.split(".").map { |n| quote_column_name(n) }].join(".")
73
+ self.class.quoted_table_names[name] ||= [name.split(".").map { |n| quote_column_name(n) }].join(".")
74
74
  end
75
75
 
76
76
  def quote_string(s) #:nodoc:
@@ -132,6 +132,42 @@ module ActiveRecord
132
132
  end
133
133
  end
134
134
 
135
+ def column_name_matcher
136
+ COLUMN_NAME
137
+ end
138
+
139
+ def column_name_with_order_matcher
140
+ COLUMN_NAME_WITH_ORDER
141
+ end
142
+
143
+ COLUMN_NAME = /
144
+ \A
145
+ (
146
+ (?:
147
+ # "table_name"."column_name" | function(one or no argument)
148
+ ((?:\w+\.|"\w+"\.)?(?:\w+|"\w+")) | \w+\((?:|\g<2>)\)
149
+ )
150
+ (?:(?:\s+AS)?\s+(?:\w+|"\w+"))?
151
+ )
152
+ (?:\s*,\s*\g<1>)*
153
+ \z
154
+ /ix
155
+
156
+ COLUMN_NAME_WITH_ORDER = /
157
+ \A
158
+ (
159
+ (?:
160
+ # "table_name"."column_name" | function(one or no argument)
161
+ ((?:\w+\.|"\w+"\.)?(?:\w+|"\w+")) | \w+\((?:|\g<2>)\)
162
+ )
163
+ (?:\s+ASC|\s+DESC)?
164
+ (?:\s+NULLS\s+(?:FIRST|LAST))?
165
+ )
166
+ (?:\s*,\s*\g<1>)*
167
+ \z
168
+ /ix
169
+ private_constant :COLUMN_NAME, :COLUMN_NAME_WITH_ORDER
170
+
135
171
  private
136
172
 
137
173
  def oracle_downcase(column_name)
@@ -7,7 +7,7 @@ module ActiveRecord
7
7
  private
8
8
 
9
9
  def visit_ColumnDefinition(o)
10
- if [:blob, :clob, :nclob].include?(sql_type = type_to_sql(o.type, o.options).downcase.to_sym)
10
+ if [:blob, :clob, :nclob].include?(sql_type = type_to_sql(o.type, **o.options).downcase.to_sym)
11
11
  if (tablespace = default_tablespace_for(sql_type))
12
12
  @lob_tablespaces ||= {}
13
13
  @lob_tablespaces[o.name] = tablespace
@@ -17,7 +17,7 @@ module ActiveRecord
17
17
  ].each do |column_type|
18
18
  module_eval <<-CODE, __FILE__, __LINE__ + 1
19
19
  def #{column_type}(*args, **options)
20
- args.each { |name| column(name, :#{column_type}, options) }
20
+ args.each { |name| column(name, :#{column_type}, **options) }
21
21
  end
22
22
  CODE
23
23
  end
@@ -198,7 +198,7 @@ module ActiveRecord
198
198
 
199
199
  def create_table(table_name, **options)
200
200
  create_sequence = options[:id] != false
201
- td = create_table_definition table_name, options
201
+ td = create_table_definition table_name, **options
202
202
 
203
203
  if options[:id] != false && !options[:as]
204
204
  pk = options.fetch(:primary_key) do
@@ -208,7 +208,7 @@ module ActiveRecord
208
208
  if pk.is_a?(Array)
209
209
  td.primary_keys pk
210
210
  else
211
- td.primary_key pk, options.fetch(:id, :primary_key), options
211
+ td.primary_key pk, options.fetch(:id, :primary_key), **options
212
212
  end
213
213
  end
214
214
 
@@ -288,7 +288,7 @@ module ActiveRecord
288
288
  end
289
289
 
290
290
  def add_index(table_name, column_name, options = {}) #:nodoc:
291
- index_name, index_type, quoted_column_names, tablespace, index_options = add_index_options(table_name, column_name, options)
291
+ index_name, index_type, quoted_column_names, tablespace, index_options = add_index_options(table_name, column_name, **options)
292
292
  execute "CREATE #{index_type} INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} (#{quoted_column_names})#{tablespace} #{index_options}"
293
293
  if index_type == "UNIQUE"
294
294
  unless /\(.*\)/.match?(quoted_column_names)
@@ -402,14 +402,14 @@ module ActiveRecord
402
402
  execute "DROP SYNONYM #{quote_table_name(name)}"
403
403
  end
404
404
 
405
- def add_reference(table_name, *args)
406
- OracleEnhanced::ReferenceDefinition.new(*args).add_to(update_table_definition(table_name, self))
405
+ def add_reference(table_name, ref_name, **options)
406
+ OracleEnhanced::ReferenceDefinition.new(ref_name, **options).add_to(update_table_definition(table_name, self))
407
407
  end
408
408
 
409
- def add_column(table_name, column_name, type, options = {}) #:nodoc:
409
+ def add_column(table_name, column_name, type, **options) #:nodoc:
410
410
  type = aliased_types(type.to_s, type)
411
411
  at = create_alter_table table_name
412
- at.add_column(column_name, type, options)
412
+ at.add_column(column_name, type, **options)
413
413
  add_column_sql = schema_creation.accept at
414
414
  add_column_sql << tablespace_for((type_to_sql(type).downcase.to_sym), nil, table_name, column_name)
415
415
  execute add_column_sql
@@ -453,7 +453,7 @@ module ActiveRecord
453
453
  end
454
454
 
455
455
  td = create_table_definition(table_name)
456
- cd = td.new_column_definition(column.name, type, options)
456
+ cd = td.new_column_definition(column.name, type, **options)
457
457
  change_column_stmt = schema_creation.accept cd
458
458
  change_column_stmt << tablespace_for((type_to_sql(type).downcase.to_sym), nil, options[:table_name], options[:column_name]) if type
459
459
  change_column_sql = "ALTER TABLE #{quote_table_name(table_name)} MODIFY #{change_column_stmt}"
@@ -619,8 +619,8 @@ module ActiveRecord
619
619
  OracleEnhanced::SchemaCreation.new self
620
620
  end
621
621
 
622
- def create_table_definition(*args)
623
- OracleEnhanced::TableDefinition.new(self, *args)
622
+ def create_table_definition(*args, **options)
623
+ OracleEnhanced::TableDefinition.new(self, *args, **options)
624
624
  end
625
625
 
626
626
  def new_column_from_field(table_name, field)
@@ -387,10 +387,22 @@ describe "OracleEnhancedConnection" do
387
387
  end
388
388
 
389
389
  describe "auto reconnection" do
390
+ include SchemaSpecHelper
391
+
390
392
  before(:all) do
391
393
  ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
392
394
  @conn = ActiveRecord::Base.connection.instance_variable_get("@connection")
393
395
  @sys_conn = ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection.create(SYS_CONNECTION_PARAMS)
396
+ schema_define do
397
+ create_table :posts, force: true
398
+ end
399
+ class ::Post < ActiveRecord::Base
400
+ end
401
+ end
402
+
403
+ after(:all) do
404
+ Object.send(:remove_const, "Post")
405
+ ActiveRecord::Base.clear_cache!
394
406
  end
395
407
 
396
408
  before(:each) do
@@ -440,6 +452,20 @@ describe "OracleEnhancedConnection" do
440
452
  expect { @conn.select("SELECT * FROM dual") }.to raise_error(OCIError)
441
453
  end
442
454
  end
455
+
456
+ it "should reconnect and execute query if connection is lost and auto retry is enabled" do
457
+ Post.create!
458
+ ActiveRecord::Base.connection.auto_retry = true
459
+ kill_current_session
460
+ expect(Post.take).not_to be_nil
461
+ end
462
+
463
+ it "should not reconnect and execute query if connection is lost and auto retry is disabled" do
464
+ Post.create!
465
+ ActiveRecord::Base.connection.auto_retry = false
466
+ kill_current_session
467
+ expect { Post.take }.to raise_error(ActiveRecord::StatementInvalid)
468
+ end
443
469
  end
444
470
 
445
471
  describe "describe table" do
@@ -21,7 +21,7 @@ describe "OracleEnhancedAdapter schema dump" do
21
21
  def create_test_posts_table(options = {})
22
22
  options[:force] = true
23
23
  schema_define do
24
- create_table :test_posts, options do |t|
24
+ create_table :test_posts, **options do |t|
25
25
  t.string :title
26
26
  t.timestamps null: true
27
27
  end
@@ -80,7 +80,8 @@ describe "OracleEnhancedAdapter schema definition" do
80
80
  describe "sequence creation parameters" do
81
81
  def create_test_employees_table(sequence_start_value = nil)
82
82
  schema_define do
83
- create_table :test_employees, sequence_start_value ? { sequence_start_value: sequence_start_value } : {} do |t|
83
+ options = sequence_start_value ? { sequence_start_value: sequence_start_value } : {}
84
+ create_table :test_employees, **options do |t|
84
85
  t.string :first_name
85
86
  t.string :last_name
86
87
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "simplecov"
4
- SimpleCov.start
5
3
  require "rubygems"
6
4
  require "bundler"
7
5
  require "yaml"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-oracle_enhanced-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0.rc2
4
+ version: 6.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raimonds Simanovskis
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-22 00:00:00.000000000 Z
11
+ date: 2020-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 6.0.0.rc2
19
+ version: 6.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 6.0.0.rc2
26
+ version: 6.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ruby-plsql
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -120,7 +120,7 @@ homepage: http://github.com/rsim/oracle-enhanced
120
120
  licenses:
121
121
  - MIT
122
122
  metadata: {}
123
- post_install_message:
123
+ post_install_message:
124
124
  rdoc_options: []
125
125
  require_paths:
126
126
  - lib
@@ -135,38 +135,38 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  - !ruby/object:Gem::Version
136
136
  version: 1.8.11
137
137
  requirements: []
138
- rubygems_version: 3.0.3
139
- signing_key:
138
+ rubygems_version: 3.1.2
139
+ signing_key:
140
140
  specification_version: 4
141
141
  summary: Oracle enhanced adapter for ActiveRecord
142
142
  test_files:
143
- - spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb
143
+ - spec/spec_helper.rb
144
+ - spec/spec_config.yaml.template
144
145
  - spec/active_record/connection_adapters/emulation/oracle_adapter_spec.rb
145
- - spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb
146
- - spec/active_record/connection_adapters/oracle_enhanced/schema_dumper_spec.rb
146
+ - spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb
147
147
  - spec/active_record/connection_adapters/oracle_enhanced/database_tasks_spec.rb
148
- - spec/active_record/connection_adapters/oracle_enhanced/quoting_spec.rb
149
148
  - spec/active_record/connection_adapters/oracle_enhanced/schema_statements_spec.rb
149
+ - spec/active_record/connection_adapters/oracle_enhanced/quoting_spec.rb
150
+ - spec/active_record/connection_adapters/oracle_enhanced/schema_dumper_spec.rb
150
151
  - spec/active_record/connection_adapters/oracle_enhanced/dbms_output_spec.rb
151
152
  - spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb
152
- - spec/active_record/connection_adapters/oracle_enhanced/context_index_spec.rb
153
- - spec/active_record/connection_adapters/oracle_enhanced/structure_dump_spec.rb
154
153
  - spec/active_record/connection_adapters/oracle_enhanced/procedures_spec.rb
154
+ - spec/active_record/connection_adapters/oracle_enhanced/structure_dump_spec.rb
155
+ - spec/active_record/connection_adapters/oracle_enhanced/context_index_spec.rb
156
+ - spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb
157
+ - spec/active_record/oracle_enhanced/type/decimal_spec.rb
155
158
  - spec/active_record/oracle_enhanced/type/national_character_string_spec.rb
156
159
  - spec/active_record/oracle_enhanced/type/dirty_spec.rb
160
+ - spec/active_record/oracle_enhanced/type/boolean_spec.rb
161
+ - spec/active_record/oracle_enhanced/type/json_spec.rb
162
+ - spec/active_record/oracle_enhanced/type/raw_spec.rb
163
+ - spec/active_record/oracle_enhanced/type/binary_spec.rb
157
164
  - spec/active_record/oracle_enhanced/type/text_spec.rb
158
165
  - spec/active_record/oracle_enhanced/type/timestamp_spec.rb
159
- - spec/active_record/oracle_enhanced/type/binary_spec.rb
160
- - spec/active_record/oracle_enhanced/type/float_spec.rb
161
- - spec/active_record/oracle_enhanced/type/raw_spec.rb
162
- - spec/active_record/oracle_enhanced/type/character_string_spec.rb
163
- - spec/active_record/oracle_enhanced/type/json_spec.rb
164
- - spec/active_record/oracle_enhanced/type/decimal_spec.rb
165
166
  - spec/active_record/oracle_enhanced/type/national_character_text_spec.rb
166
- - spec/active_record/oracle_enhanced/type/boolean_spec.rb
167
+ - spec/active_record/oracle_enhanced/type/character_string_spec.rb
167
168
  - spec/active_record/oracle_enhanced/type/integer_spec.rb
168
- - spec/spec_config.yaml.template
169
+ - spec/active_record/oracle_enhanced/type/float_spec.rb
169
170
  - spec/support/alter_system_set_open_cursors.sql
170
171
  - spec/support/alter_system_user_password.sql
171
172
  - spec/support/create_oracle_enhanced_users.sql
172
- - spec/spec_helper.rb