activerecord-oracle_enhanced-adapter 6.0.0.rc1 → 6.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +63 -13
- data/README.md +12 -1
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +58 -41
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +16 -6
- data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +38 -2
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +2 -0
- data/lib/ojdbc8.jar +0 -0
- data/spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb +54 -0
- data/spec/spec_helper.rb +0 -2
- metadata +25 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 052b872f1a9b0e25deb107b79b568226bd0083f3747323b566cc61af3316004d
|
4
|
+
data.tar.gz: ba283f9be0de33aceb818753656a4887da42f6fd317036c9d34fa930aa8e9723
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b4a606efdf65e2cc08a5e78f07a6d5d8750710f9c7660dfa116b885a151873f995472c01890e22716eaa1e74d9ee5527282c579d41c02978b525b2ea676b6b5
|
7
|
+
data.tar.gz: a937ae9b1fe755be2bfb2d100b0564bf25d1e6e23730947a09d06450e50431ee3c0d864f8cf472cbacc99e2a32b6b99d8cf8e959b86d04aabc75352798123c9c
|
data/History.md
CHANGED
@@ -1,3 +1,53 @@
|
|
1
|
+
## 6.0.3 / 2020-06-16
|
2
|
+
|
3
|
+
* Changes and bug fixes
|
4
|
+
* Auto retry works for other `exec_*` methods [#1976, #1981]
|
5
|
+
* Allow column name with function (e.g. `length(title)`) as safe SQL string [#2017, #2018]
|
6
|
+
|
7
|
+
* CI
|
8
|
+
* CI against latest Ruby versions [#1979]
|
9
|
+
|
10
|
+
## 6.0.2 / 2019-12-25
|
11
|
+
|
12
|
+
* Changes and bug fixes
|
13
|
+
* Uninstall SimpleCov [#1968]
|
14
|
+
|
15
|
+
## 6.0.1 / 2019-12-20
|
16
|
+
|
17
|
+
* Changes and bug fixes
|
18
|
+
* Address `undefined local variable or method `sql' [#1932 #1962 #1963]
|
19
|
+
|
20
|
+
* CI
|
21
|
+
* CI against Ruby 2.6.4 and Ruby 2.5.6 [#1922]
|
22
|
+
|
23
|
+
## 6.0.0 / 2019-08-17
|
24
|
+
|
25
|
+
* Major changes, including changes since 6.0.0.beta1
|
26
|
+
|
27
|
+
* Support Rails 6.0.0
|
28
|
+
* Rails 6 requires Ruby 2.5 [#1801]
|
29
|
+
* Support longer identifier for Oracle database 12.2 or higher [#1703 #1705]
|
30
|
+
* Introduce `use_shorter_identifier` [#1707]
|
31
|
+
* Change `default_sequence_start_value` from 10000 to 1 [#1636]
|
32
|
+
* Address `ORA-01795: maximum number of expressions in a list is 1000`
|
33
|
+
|
34
|
+
* CI
|
35
|
+
* CI against JRuby 9.2.8.0 #1912
|
36
|
+
|
37
|
+
## 6.0.0.rc3 / 2019-07-27
|
38
|
+
|
39
|
+
* Changes and bug fixes
|
40
|
+
* Share the column and table name quote cache between connections [#1901 #1903]
|
41
|
+
|
42
|
+
## 6.0.0.rc2 / 2019-07-23
|
43
|
+
|
44
|
+
* Major changes
|
45
|
+
* Support Rails 6.0.0 rc2
|
46
|
+
* Add TCP keepalive and TCP keepalive time configurations [#1874 #1877]
|
47
|
+
|
48
|
+
* Changes and bug fixes
|
49
|
+
* Update bug report templates for Oracle enhanced adapter 6.0 [#1873]
|
50
|
+
|
1
51
|
## 6.0.0.rc1 / 2019-04-25
|
2
52
|
|
3
53
|
* Major changes
|
@@ -82,7 +132,7 @@
|
|
82
132
|
* Restore old Code Climate behavior [#1716]
|
83
133
|
* Do not install bundler explicitly [#1725]
|
84
134
|
|
85
|
-
* RuboCop
|
135
|
+
* RuboCop
|
86
136
|
|
87
137
|
* Add RuboCop to Gemfile [#1841]
|
88
138
|
* Bump RuboCop to 0.63.0 [#1816]
|
@@ -279,7 +329,7 @@
|
|
279
329
|
* Remove `add_runtime_dependency` with arel [#1385]
|
280
330
|
* Move methods for synonyms out of `SchemaStatementsExt` [#1387]
|
281
331
|
* Remove incorrect prepend to `ActiveRecord::ColumnDumper` [#1394]
|
282
|
-
* Handle `ActiveRecord::SchemaDumper` by `adapter_name` [#1395]
|
332
|
+
* Handle `ActiveRecord::SchemaDumper` by `adapter_name` [#1395]
|
283
333
|
* Rewrite `remove_prefix_and_suffix` to be similar with super #1401
|
284
334
|
* `remove_prefix_and_suffix` handles dollar sign by `Regexp#escape` [#1402]
|
285
335
|
* `prepare_column_options` is now private [#1429]
|
@@ -543,7 +593,7 @@
|
|
543
593
|
* Use the latest arel master while developing alpha version [#1115]
|
544
594
|
* Bump Arel to 8.0 [#1120, #1121, #1124]
|
545
595
|
* Use released Arel 8 [#1205]
|
546
|
-
* Remove duplicate license information [#965]
|
596
|
+
* Remove duplicate license information [#965]
|
547
597
|
* Clean up comments and un-commented specs for table comment feature [#971]
|
548
598
|
* Use Rails migration `create_table` to create table and sequence [#991]
|
549
599
|
* Removed a invalid spec about TIMESTAMP column [#1020]
|
@@ -931,7 +981,7 @@
|
|
931
981
|
* Address `add_column_options!': undefined method `quote_value' [#647]
|
932
982
|
* Remove dirty tracking methods [#883]
|
933
983
|
* Use arel master branch for rails5 development [#645]
|
934
|
-
* Bump ruby-oci8 version to 2.2.0 or higher [#775]
|
984
|
+
* Bump ruby-oci8 version to 2.2.0 or higher [#775]
|
935
985
|
* Remove jeweler dependency [#766]
|
936
986
|
* Remove required_rubygems_version [#719]
|
937
987
|
* Remove journey which is already part of Rails [#701]
|
@@ -969,13 +1019,13 @@
|
|
969
1019
|
* Rails 5 : create table with primary key trigger with default primary key not returning id [#912]
|
970
1020
|
* Rails 5 : dirty object tracking not working correctly for CLOB [#911]
|
971
1021
|
* Rails 5 : handling of CLOB columns get failures [#910]
|
972
|
-
* Rails 5 : SQL with bind parameters when NLS_NUMERIC_CHARACTERS is set to ', '
|
1022
|
+
* Rails 5 : SQL with bind parameters when NLS_NUMERIC_CHARACTERS is set to ', '
|
973
1023
|
show Java::JavaSql::SQLSyntaxErrorException: / ORA-01722: invalid number [#909]
|
974
1024
|
* Rails 5 : explain should explain query with binds got Java::JavaSql::SQLException: Invalid column index [#908]
|
975
1025
|
- CRuby and JRuby
|
976
1026
|
* Rails 5 : create table with primary key trigger not returning id [#907]
|
977
1027
|
* 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"
|
1028
|
+
* Rails 5 : has_and_belongs_to_many test gets ORA-01400 since primary key column "ID"
|
979
1029
|
not included in insert statement [#856, rails/rails#25388]
|
980
1030
|
* Rails 5 : undefined method `to_i' for #<Arel::Nodes::BindParam:0x00000002c92910> [#848, rails/arel#438]
|
981
1031
|
|
@@ -1038,11 +1088,11 @@
|
|
1038
1088
|
|
1039
1089
|
* Changes and bug fixes since 1.6.0
|
1040
1090
|
|
1041
|
-
* Oracle enhanced adapter v1.6 requires ActiveRecord 4.2.1 or higher,
|
1091
|
+
* Oracle enhanced adapter v1.6 requires ActiveRecord 4.2.1 or higher,
|
1042
1092
|
ActiveRecord 4.2.0 is not supported.[#651, #652]
|
1043
1093
|
* Fix serialized value becomes from yaml to string once saved [#655, #657]
|
1044
1094
|
* Update Ruby version in readme [#654]
|
1045
|
-
* Update unit test matcher to skip sql statements to get `table` metadata [#653]
|
1095
|
+
* Update unit test matcher to skip sql statements to get `table` metadata [#653]
|
1046
1096
|
|
1047
1097
|
## 1.6.0 / 2015-06-25
|
1048
1098
|
|
@@ -1125,7 +1175,7 @@
|
|
1125
1175
|
* Change log method signiture to support Rails 4.2 [#539]
|
1126
1176
|
* Enable loading spec configuration from config file instead of env [#550]
|
1127
1177
|
* Rails42: Issue with non-existent columns [#545, #551]
|
1128
|
-
* Squelch warning "#column_for_attribute` will return a null object
|
1178
|
+
* Squelch warning "#column_for_attribute` will return a null object
|
1129
1179
|
for non-existent columns in Rails 5. Use `#has_attribute?`" [#551]
|
1130
1180
|
* Use arel 6-0-stable [#565]
|
1131
1181
|
* Support 'Y' as true and 'N' as false in Rails 4.2 [#574, #573]
|
@@ -1136,7 +1186,7 @@
|
|
1136
1186
|
* Rails 4.2 Address ArgumentError: wrong number of arguments (1 for 2) at `quote_value` [#511]
|
1137
1187
|
* Address ORA-00932: inconsistent datatypes: expected NUMBER got DATE [#538]
|
1138
1188
|
* Remove duplicate alias_method_chain for indexes [#560]
|
1139
|
-
* Address RangeError: 6000000000 is out of range for ActiveRecord::Type::Integer
|
1189
|
+
* Address RangeError: 6000000000 is out of range for ActiveRecord::Type::Integer
|
1140
1190
|
with limit 4 [#578]
|
1141
1191
|
* Return foreign_keys_without_oracle_enhanced when non Oracle database used [#583]
|
1142
1192
|
* Add missing database_tasks.rb to gemspec [#585]
|
@@ -1181,7 +1231,7 @@
|
|
1181
1231
|
* Enhancements
|
1182
1232
|
* Oracle NUMBER datatype can be handled as Rails :float datatype [#418]
|
1183
1233
|
- Default NUMBER datatype handled as :decimal to keep compatibility
|
1184
|
-
- Configured by setting `self.number_datatype_coercion = :float`
|
1234
|
+
- Configured by setting `self.number_datatype_coercion = :float`
|
1185
1235
|
* Add link to supported Oracle database version, JDK and Oracle JDBC Driver version [#438]
|
1186
1236
|
* Support `without_prepared_statements?` to handle `unprepared_statement` [#447]
|
1187
1237
|
|
@@ -1263,7 +1313,7 @@
|
|
1263
1313
|
* Create indexes automatically for references and belongs_to [#183]
|
1264
1314
|
* Use the index name explicitly provided in a migration when reverting [#296]
|
1265
1315
|
* Rename indexes when a table or column is renamed [#286]
|
1266
|
-
* Support refactored remove_column [#172]
|
1316
|
+
* Support refactored remove_column [#172]
|
1267
1317
|
* Support allowed_index_name_length method [#285]
|
1268
1318
|
* Remove schema prefix from sequence name if present before truncating [#155]
|
1269
1319
|
* Bumped jeweler, ruby-plsql and ruby-oci8 version [#176]
|
@@ -1579,7 +1629,7 @@
|
|
1579
1629
|
* Added support for NVARCHAR2 column type
|
1580
1630
|
* Bug fixes:
|
1581
1631
|
* Do not call write_lobs callback when custom create or update methods are defined
|
1582
|
-
|
1632
|
+
|
1583
1633
|
### 1.1.5 / 2008-07-27
|
1584
1634
|
|
1585
1635
|
* 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
|
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.
|
1
|
+
6.0.3
|
@@ -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
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
@statements
|
32
|
-
|
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
|
-
|
35
|
+
cursor = @statements[sql]
|
35
36
|
|
36
|
-
|
37
|
+
cursor.bind_params(type_casted_binds)
|
37
38
|
|
38
|
-
|
39
|
-
|
39
|
+
cached = true
|
40
|
+
end
|
40
41
|
|
41
|
-
|
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
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
@statements
|
105
|
-
|
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
|
-
|
113
|
+
cursor.bind_params(type_casted_binds)
|
108
114
|
|
109
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
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
|
-
|
145
|
-
|
147
|
+
if @statements.key?(sql)
|
148
|
+
cursor = @statements[sql]
|
149
|
+
else
|
150
|
+
cursor = @statements[sql] = @connection.prepare(sql)
|
151
|
+
end
|
146
152
|
|
147
|
-
|
153
|
+
cursor.bind_params(type_casted_binds)
|
148
154
|
|
149
|
-
|
150
|
-
|
155
|
+
cached = true
|
156
|
+
end
|
151
157
|
|
152
|
-
|
153
|
-
|
154
|
-
|
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
|
@@ -297,6 +301,8 @@ module ActiveRecord
|
|
297
301
|
# The OracleEnhancedOCIFactory factors out the code necessary to connect and
|
298
302
|
# configure an Oracle/OCI connection.
|
299
303
|
class OracleEnhancedOCIFactory #:nodoc:
|
304
|
+
DEFAULT_TCP_KEEPALIVE_TIME = 600
|
305
|
+
|
300
306
|
def self.new_connection(config)
|
301
307
|
# to_s needed if username, password or database is specified as number in database.yml file
|
302
308
|
username = config[:username] && config[:username].to_s
|
@@ -326,11 +332,13 @@ module ActiveRecord
|
|
326
332
|
else
|
327
333
|
database
|
328
334
|
end
|
329
|
-
|
335
|
+
|
336
|
+
OCI8.properties[:tcp_keepalive] = config[:tcp_keepalive] == false ? false : true
|
330
337
|
begin
|
331
|
-
OCI8.properties[:tcp_keepalive_time] =
|
338
|
+
OCI8.properties[:tcp_keepalive_time] = config[:tcp_keepalive_time] || DEFAULT_TCP_KEEPALIVE_TIME
|
332
339
|
rescue NotImplementedError
|
333
340
|
end
|
341
|
+
|
334
342
|
conn = OCI8.new username, password, connection_string, privilege
|
335
343
|
conn.autocommit = true
|
336
344
|
conn.non_blocking = true if async
|
@@ -419,13 +427,11 @@ class OCI8EnhancedAutoRecover < DelegateClass(OCI8) #:nodoc:
|
|
419
427
|
LOST_CONNECTION_ERROR_CODES = [ 28, 1012, 3113, 3114, 3135 ] #:nodoc:
|
420
428
|
|
421
429
|
# Adds auto-recovery functionality.
|
422
|
-
|
423
|
-
# See: http://www.jiubao.org/ruby-oci8/api.en.html#label-11
|
424
|
-
def exec(sql, *bindvars, &block) #:nodoc:
|
430
|
+
def with_retry #:nodoc:
|
425
431
|
should_retry = self.class.auto_retry? && autocommit?
|
426
432
|
|
427
433
|
begin
|
428
|
-
|
434
|
+
yield
|
429
435
|
rescue OCIException => e
|
430
436
|
raise unless e.is_a?(OCIError) && LOST_CONNECTION_ERROR_CODES.include?(e.code)
|
431
437
|
@active = false
|
@@ -435,5 +441,9 @@ class OCI8EnhancedAutoRecover < DelegateClass(OCI8) #:nodoc:
|
|
435
441
|
retry
|
436
442
|
end
|
437
443
|
end
|
444
|
+
|
445
|
+
def exec(sql, *bindvars, &block) #:nodoc:
|
446
|
+
with_retry { @connection.exec(sql, *bindvars, &block) }
|
447
|
+
end
|
438
448
|
end
|
439
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
|
-
|
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
|
-
|
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)
|
@@ -115,6 +115,8 @@ module ActiveRecord
|
|
115
115
|
# * <tt>:time_zone</tt> - database session time zone
|
116
116
|
# (it is recommended to set it using ENV['TZ'] which will be then also used for database session time zone)
|
117
117
|
# * <tt>:schema</tt> - database schema which holds schema objects.
|
118
|
+
# * <tt>:tcp_keepalive</tt> - TCP keepalive is enabled for OCI client, defaults to true
|
119
|
+
# * <tt>:tcp_keepalive_time</tt> - TCP keepalive time for OCI client, defaults to 600
|
118
120
|
#
|
119
121
|
# Optionals NLS parameters:
|
120
122
|
#
|
data/lib/ojdbc8.jar
ADDED
Binary file
|
@@ -135,6 +135,34 @@ describe "OracleEnhancedConnection" do
|
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
|
+
if defined?(OCI8)
|
139
|
+
describe "with TCP keepalive parameters" do
|
140
|
+
it "should use database default `tcp_keepalive` value true by default" do
|
141
|
+
ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection.create(CONNECTION_PARAMS)
|
142
|
+
|
143
|
+
expect(OCI8.properties[:tcp_keepalive]).to be true
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should use modified `tcp_keepalive` value false" do
|
147
|
+
ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection.create(CONNECTION_PARAMS.dup.merge(tcp_keepalive: false))
|
148
|
+
|
149
|
+
expect(OCI8.properties[:tcp_keepalive]).to be false
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should use database default `tcp_keepalive_time` value 600 by default" do
|
153
|
+
ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection.create(CONNECTION_PARAMS)
|
154
|
+
|
155
|
+
expect(OCI8.properties[:tcp_keepalive_time]).to eq(600)
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should use modified `tcp_keepalive_time` value 3000" do
|
159
|
+
ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection.create(CONNECTION_PARAMS.dup.merge(tcp_keepalive_time: 3000))
|
160
|
+
|
161
|
+
expect(OCI8.properties[:tcp_keepalive_time]).to eq(3000)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
138
166
|
describe "with non-string parameters" do
|
139
167
|
before(:all) do
|
140
168
|
params = CONNECTION_PARAMS.dup
|
@@ -359,10 +387,22 @@ describe "OracleEnhancedConnection" do
|
|
359
387
|
end
|
360
388
|
|
361
389
|
describe "auto reconnection" do
|
390
|
+
include SchemaSpecHelper
|
391
|
+
|
362
392
|
before(:all) do
|
363
393
|
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
364
394
|
@conn = ActiveRecord::Base.connection.instance_variable_get("@connection")
|
365
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!
|
366
406
|
end
|
367
407
|
|
368
408
|
before(:each) do
|
@@ -412,6 +452,20 @@ describe "OracleEnhancedConnection" do
|
|
412
452
|
expect { @conn.select("SELECT * FROM dual") }.to raise_error(OCIError)
|
413
453
|
end
|
414
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
|
415
469
|
end
|
416
470
|
|
417
471
|
describe "describe table" do
|
data/spec/spec_helper.rb
CHANGED
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.
|
4
|
+
version: 6.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raimonds Simanovskis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-16 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
|
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
|
26
|
+
version: 6.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: ruby-plsql
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- lib/active_record/type/oracle_enhanced/timestampltz.rb
|
87
87
|
- lib/active_record/type/oracle_enhanced/timestamptz.rb
|
88
88
|
- lib/activerecord-oracle_enhanced-adapter.rb
|
89
|
+
- lib/ojdbc8.jar
|
89
90
|
- spec/active_record/connection_adapters/emulation/oracle_adapter_spec.rb
|
90
91
|
- spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb
|
91
92
|
- spec/active_record/connection_adapters/oracle_enhanced/context_index_spec.rb
|
@@ -135,38 +136,38 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
136
|
- !ruby/object:Gem::Version
|
136
137
|
version: 1.8.11
|
137
138
|
requirements: []
|
138
|
-
rubygems_version: 3.
|
139
|
+
rubygems_version: 3.1.2
|
139
140
|
signing_key:
|
140
141
|
specification_version: 4
|
141
142
|
summary: Oracle enhanced adapter for ActiveRecord
|
142
143
|
test_files:
|
143
|
-
- spec/
|
144
|
-
- spec/
|
145
|
-
- spec/
|
146
|
-
- spec/active_record/oracle_enhanced/type/integer_spec.rb
|
147
|
-
- spec/active_record/oracle_enhanced/type/national_character_string_spec.rb
|
148
|
-
- spec/active_record/oracle_enhanced/type/raw_spec.rb
|
149
|
-
- spec/active_record/oracle_enhanced/type/json_spec.rb
|
150
|
-
- spec/active_record/oracle_enhanced/type/float_spec.rb
|
151
|
-
- spec/active_record/oracle_enhanced/type/timestamp_spec.rb
|
144
|
+
- spec/support/alter_system_user_password.sql
|
145
|
+
- spec/support/create_oracle_enhanced_users.sql
|
146
|
+
- spec/support/alter_system_set_open_cursors.sql
|
152
147
|
- spec/active_record/oracle_enhanced/type/boolean_spec.rb
|
148
|
+
- spec/active_record/oracle_enhanced/type/float_spec.rb
|
149
|
+
- spec/active_record/oracle_enhanced/type/raw_spec.rb
|
150
|
+
- spec/active_record/oracle_enhanced/type/national_character_string_spec.rb
|
153
151
|
- spec/active_record/oracle_enhanced/type/binary_spec.rb
|
152
|
+
- spec/active_record/oracle_enhanced/type/character_string_spec.rb
|
154
153
|
- spec/active_record/oracle_enhanced/type/decimal_spec.rb
|
154
|
+
- spec/active_record/oracle_enhanced/type/json_spec.rb
|
155
155
|
- spec/active_record/oracle_enhanced/type/national_character_text_spec.rb
|
156
|
-
- spec/active_record/
|
157
|
-
- spec/active_record/
|
158
|
-
- spec/active_record/
|
156
|
+
- spec/active_record/oracle_enhanced/type/timestamp_spec.rb
|
157
|
+
- spec/active_record/oracle_enhanced/type/dirty_spec.rb
|
158
|
+
- spec/active_record/oracle_enhanced/type/integer_spec.rb
|
159
|
+
- spec/active_record/oracle_enhanced/type/text_spec.rb
|
160
|
+
- spec/active_record/connection_adapters/oracle_enhanced/database_tasks_spec.rb
|
159
161
|
- spec/active_record/connection_adapters/oracle_enhanced/dbms_output_spec.rb
|
160
162
|
- spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb
|
161
|
-
- spec/active_record/connection_adapters/oracle_enhanced/
|
163
|
+
- spec/active_record/connection_adapters/oracle_enhanced/context_index_spec.rb
|
162
164
|
- spec/active_record/connection_adapters/oracle_enhanced/structure_dump_spec.rb
|
163
|
-
- spec/active_record/connection_adapters/oracle_enhanced/procedures_spec.rb
|
164
|
-
- spec/active_record/connection_adapters/oracle_enhanced/quoting_spec.rb
|
165
165
|
- spec/active_record/connection_adapters/oracle_enhanced/schema_dumper_spec.rb
|
166
|
-
- spec/active_record/connection_adapters/oracle_enhanced/
|
166
|
+
- spec/active_record/connection_adapters/oracle_enhanced/schema_statements_spec.rb
|
167
|
+
- spec/active_record/connection_adapters/oracle_enhanced/quoting_spec.rb
|
168
|
+
- spec/active_record/connection_adapters/oracle_enhanced/procedures_spec.rb
|
167
169
|
- spec/active_record/connection_adapters/emulation/oracle_adapter_spec.rb
|
168
|
-
- spec/
|
169
|
-
- spec/
|
170
|
-
- spec/support/create_oracle_enhanced_users.sql
|
170
|
+
- spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb
|
171
|
+
- spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb
|
171
172
|
- spec/spec_helper.rb
|
172
173
|
- spec/spec_config.yaml.template
|