activerecord-oracle_enhanced-adapter 5.2.0 → 5.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +60 -0
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +9 -19
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +8 -4
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +5 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +22 -1
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +22 -11
- data/spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb +35 -7
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +20 -10
- data/spec/spec_helper.rb +0 -2
- metadata +23 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa24e2267bec0862bb898b8f03c11af04a34543d38f75e8b39a5b46000009437
|
4
|
+
data.tar.gz: '0485525d25c1f4307c1e9b958cd2f1b286bc5d10542e2fd8615e499a00c989c2'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e70d58d735fec37fd8e19122f37b284397f152c911e3baf8127d8828cefd7b9f139d1acf2f3e147def7c82be26decd7e4f4eb10e85e63489ef6933ab089f83b7
|
7
|
+
data.tar.gz: 5651ab5ab00219a433b7281959d51068ea47dcd33648761cd4dc4f22c69f285dd79a8c73e262fdabe81042e9751dcb02021392c472649f7662b593daf1187d60
|
data/History.md
CHANGED
@@ -1,3 +1,63 @@
|
|
1
|
+
## 5.2.8 / 2019-12-25
|
2
|
+
|
3
|
+
* Changes and bug fixes
|
4
|
+
* Uninstall SimpleCov [#1968 #1970]
|
5
|
+
|
6
|
+
## 5.2.7 / 2019-12-20
|
7
|
+
|
8
|
+
* Changes and bug fixes
|
9
|
+
* Address undefined local variable or method sql' [#1932 #1962 #1964]
|
10
|
+
* CI against Ruby 2.6.4 and Ruby 2.5.6 [#1922]
|
11
|
+
* Lock simplecov version for Ruby 2.2 and 2.3 [#1902]
|
12
|
+
|
13
|
+
## 5.2.6 / 2019-05-17
|
14
|
+
|
15
|
+
* Changes and bug fixes
|
16
|
+
* Add TCP keepalive and TCP keepalive time configurations [#1874 #1878]
|
17
|
+
* CI against Ruby 2.6.2 and 2.5.5 #1849
|
18
|
+
* CI against Ruby 2.4.6 #1858
|
19
|
+
|
20
|
+
## 5.2.5 / 2019-03-05
|
21
|
+
|
22
|
+
* Changes and bug fixes
|
23
|
+
* `references` column type should be :integer, not :bigint [#1831 #1832 #1835]
|
24
|
+
* CI against Ruby 2.6.1 [#1821 #1822]
|
25
|
+
* CI against JRuby 9.2.6.0 [#1824 #1828]
|
26
|
+
* CI against Ruby 2.6 and bump other Ruby versions [#1806 #1807]
|
27
|
+
* Install bundler and fallback to 1.7.3 if Bundler 2 is not available [#1811]
|
28
|
+
* Use i18n 1.2 for JRuby now [#1804 #1805]
|
29
|
+
* Add `allow_railures` for jruby-head until #1833 resolved [#1834 #1836]
|
30
|
+
|
31
|
+
## 5.2.4 / 2018-11-29
|
32
|
+
|
33
|
+
* Changes and bug fixes
|
34
|
+
* Stop using NativeException [#1666 #1761 #1762]
|
35
|
+
|
36
|
+
## 5.2.3 / 2018-08-08
|
37
|
+
|
38
|
+
* Changes and bug fixes
|
39
|
+
* Introduce column cache per connection [#1744 #1750]
|
40
|
+
* Use `cursor_sharing` = force by default again [#1745 #1748]
|
41
|
+
* Add `table_name` search condition to `indexes(table_name)` method [#1747 #1749]
|
42
|
+
* Suppress warning `BigDecimal.new` is deprecated [#1742 #1743]
|
43
|
+
* Do not install bundler explicitly [#1725 #1726]
|
44
|
+
* Add `allow_railures` for jruby-head until #1737 resolved [#1739 #1740]
|
45
|
+
* CI against JRuby 9.2.0.0 [#1728 #1741]
|
46
|
+
* Do not run CI against older version of JRuby [#1741]
|
47
|
+
|
48
|
+
## 5.2.2 / 2018-04-28
|
49
|
+
|
50
|
+
* Changes and bug fixes
|
51
|
+
* Use SQL literals for `column_definitions` and `pk_and_sequence_for` [#1678 #1713 #1714]
|
52
|
+
* Memoize if the table needs to prefetch primary key[#1673 #1699 #1700]
|
53
|
+
* CI with JRuby 9.1.17.0 [#1710]
|
54
|
+
* Remove `rails/arel` from Gemfile [#1711 #1712]
|
55
|
+
|
56
|
+
## 5.2.1 / 2018-04-15
|
57
|
+
|
58
|
+
* Changes and bug fixes
|
59
|
+
* Memoize if the table needs to prefetch primary key[#1673 #1699 #1700]
|
60
|
+
|
1
61
|
## 5.2.0 / 2018-04-10
|
2
62
|
|
3
63
|
* Major changes and fixes
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.2.
|
1
|
+
5.2.8
|
@@ -263,7 +263,7 @@ module ActiveRecord
|
|
263
263
|
value = klass.attribute_types[col.name].serialize(value)
|
264
264
|
end
|
265
265
|
uncached do
|
266
|
-
unless lob_record = select_one(<<-SQL.strip.gsub(/\s+/, " "), "Writable Large Object")
|
266
|
+
unless lob_record = select_one(sql = <<-SQL.strip.gsub(/\s+/, " "), "Writable Large Object")
|
267
267
|
SELECT #{quote_column_name(col.name)} FROM #{quote_table_name(table_name)}
|
268
268
|
WHERE #{quote_column_name(klass.primary_key)} = #{id} FOR UPDATE
|
269
269
|
SQL
|
@@ -150,7 +150,7 @@ module ActiveRecord
|
|
150
150
|
# @raw_connection.setDefaultRowPrefetch(prefetch_rows) if prefetch_rows
|
151
151
|
end
|
152
152
|
|
153
|
-
cursor_sharing = config[:cursor_sharing]
|
153
|
+
cursor_sharing = config[:cursor_sharing] || "force"
|
154
154
|
exec "alter session set cursor_sharing = #{cursor_sharing}" if cursor_sharing
|
155
155
|
|
156
156
|
# Initialize NLS parameters
|
@@ -209,13 +209,9 @@ module ActiveRecord
|
|
209
209
|
def ping
|
210
210
|
exec_no_retry("select 1 from dual")
|
211
211
|
@active = true
|
212
|
-
rescue
|
212
|
+
rescue Java::JavaSql::SQLException => e
|
213
213
|
@active = false
|
214
|
-
|
215
|
-
raise OracleEnhanced::ConnectionException, e.message
|
216
|
-
else
|
217
|
-
raise
|
218
|
-
end
|
214
|
+
raise OracleEnhanced::ConnectionException, e.message
|
219
215
|
end
|
220
216
|
|
221
217
|
# Resets connection, by logging off and creating a new connection.
|
@@ -224,13 +220,9 @@ module ActiveRecord
|
|
224
220
|
begin
|
225
221
|
new_connection(@config)
|
226
222
|
@active = true
|
227
|
-
rescue
|
223
|
+
rescue Java::JavaSql::SQLException => e
|
228
224
|
@active = false
|
229
|
-
|
230
|
-
raise OracleEnhanced::ConnectionException, e.message
|
231
|
-
else
|
232
|
-
raise
|
233
|
-
end
|
225
|
+
raise OracleEnhanced::ConnectionException, e.message
|
234
226
|
end
|
235
227
|
end
|
236
228
|
|
@@ -239,8 +231,8 @@ module ActiveRecord
|
|
239
231
|
should_retry = auto_retry? && autocommit?
|
240
232
|
begin
|
241
233
|
yield if block_given?
|
242
|
-
rescue
|
243
|
-
raise unless e.message =~ /^
|
234
|
+
rescue Java::JavaSql::SQLException => e
|
235
|
+
raise unless e.message =~ /^(Closed Connection|Io exception:|No more data to read from socket|IO Error:)/
|
244
236
|
@active = false
|
245
237
|
raise unless should_retry
|
246
238
|
should_retry = false
|
@@ -455,11 +447,9 @@ module ActiveRecord
|
|
455
447
|
super
|
456
448
|
end
|
457
449
|
|
458
|
-
# Return
|
450
|
+
# Return java.sql.SQLException error code
|
459
451
|
def error_code(exception)
|
460
452
|
case exception
|
461
|
-
when NativeException
|
462
|
-
exception.cause.getErrorCode
|
463
453
|
when Java::JavaSql::SQLException
|
464
454
|
exception.getErrorCode
|
465
455
|
else
|
@@ -476,7 +466,7 @@ module ActiveRecord
|
|
476
466
|
elsif d.isInt
|
477
467
|
Integer(d.stringValue)
|
478
468
|
else
|
479
|
-
BigDecimal
|
469
|
+
BigDecimal(d.stringValue)
|
480
470
|
end
|
481
471
|
when :BINARY_FLOAT
|
482
472
|
rset.getFloat(i)
|
@@ -124,7 +124,7 @@ module ActiveRecord
|
|
124
124
|
when Type::OracleEnhanced::Raw
|
125
125
|
@raw_cursor.bind_param(position, OracleEnhanced::Quoting.encode_raw(value))
|
126
126
|
when ActiveModel::Type::Decimal
|
127
|
-
@raw_cursor.bind_param(position, BigDecimal
|
127
|
+
@raw_cursor.bind_param(position, BigDecimal(value.to_s))
|
128
128
|
when NilClass
|
129
129
|
@raw_cursor.bind_param(position, nil, String)
|
130
130
|
else
|
@@ -285,6 +285,8 @@ module ActiveRecord
|
|
285
285
|
# The OracleEnhancedOCIFactory factors out the code necessary to connect and
|
286
286
|
# configure an Oracle/OCI connection.
|
287
287
|
class OracleEnhancedOCIFactory #:nodoc:
|
288
|
+
DEFAULT_TCP_KEEPALIVE_TIME = 600
|
289
|
+
|
288
290
|
def self.new_connection(config)
|
289
291
|
# to_s needed if username, password or database is specified as number in database.yml file
|
290
292
|
username = config[:username] && config[:username].to_s
|
@@ -295,7 +297,7 @@ module ActiveRecord
|
|
295
297
|
privilege = config[:privilege] && config[:privilege].to_sym
|
296
298
|
async = config[:allow_concurrency]
|
297
299
|
prefetch_rows = config[:prefetch_rows] || 100
|
298
|
-
cursor_sharing = config[:cursor_sharing]
|
300
|
+
cursor_sharing = config[:cursor_sharing] || "force"
|
299
301
|
# get session time_zone from configuration or from TZ environment variable
|
300
302
|
time_zone = config[:time_zone] || ENV["TZ"]
|
301
303
|
|
@@ -314,11 +316,13 @@ module ActiveRecord
|
|
314
316
|
else
|
315
317
|
database
|
316
318
|
end
|
317
|
-
|
319
|
+
|
320
|
+
OCI8.properties[:tcp_keepalive] = config[:tcp_keepalive] == false ? false : true
|
318
321
|
begin
|
319
|
-
OCI8.properties[:tcp_keepalive_time] =
|
322
|
+
OCI8.properties[:tcp_keepalive_time] = config[:tcp_keepalive_time] || DEFAULT_TCP_KEEPALIVE_TIME
|
320
323
|
rescue NotImplementedError
|
321
324
|
end
|
325
|
+
|
322
326
|
conn = OCI8.new username, password, connection_string, privilege
|
323
327
|
conn.autocommit = true
|
324
328
|
conn.non_blocking = true if async
|
@@ -83,7 +83,7 @@ module ActiveRecord
|
|
83
83
|
(owner, table_name, db_link) = @connection.describe(table_name)
|
84
84
|
default_tablespace_name = default_tablespace
|
85
85
|
|
86
|
-
result = select_all(<<-SQL.strip.gsub(/\s+/, " "), "indexes", [bind_string("owner", owner), bind_string("owner", owner)])
|
86
|
+
result = select_all(<<-SQL.strip.gsub(/\s+/, " "), "indexes", [bind_string("owner", owner), bind_string("owner", owner), bind_string("table_name", table_name)])
|
87
87
|
SELECT LOWER(i.table_name) AS table_name, LOWER(i.index_name) AS index_name, i.uniqueness,
|
88
88
|
i.index_type, i.ityp_owner, i.ityp_name, i.parameters,
|
89
89
|
LOWER(i.tablespace_name) AS tablespace_name,
|
@@ -97,6 +97,7 @@ module ActiveRecord
|
|
97
97
|
c.column_name = atc.column_name AND i.owner = atc.owner AND atc.hidden_column = 'NO'
|
98
98
|
WHERE i.owner = :owner
|
99
99
|
AND i.table_owner = :owner
|
100
|
+
AND i.table_name = :table_name
|
100
101
|
AND NOT EXISTS (SELECT uc.index_name FROM all_constraints uc
|
101
102
|
WHERE uc.index_name = i.index_name AND uc.owner = i.owner AND uc.constraint_type = 'P')
|
102
103
|
ORDER BY i.index_name, c.column_position
|
@@ -152,6 +153,14 @@ module ActiveRecord
|
|
152
153
|
all_schema_indexes.select { |i| i.table == table_name }
|
153
154
|
end
|
154
155
|
|
156
|
+
def columns(table_name)
|
157
|
+
table_name = table_name.to_s
|
158
|
+
if @columns_cache[table_name]
|
159
|
+
@columns_cache[table_name]
|
160
|
+
else
|
161
|
+
@columns_cache[table_name] = super(table_name)
|
162
|
+
end
|
163
|
+
end
|
155
164
|
# Additional options for +create_table+ method in migration files.
|
156
165
|
#
|
157
166
|
# You can specify individual starting value in table creation migration file, e.g.:
|
@@ -248,6 +257,8 @@ module ActiveRecord
|
|
248
257
|
execute "DROP SEQUENCE #{quote_table_name(seq_name)}" rescue nil
|
249
258
|
rescue ActiveRecord::StatementInvalid => e
|
250
259
|
raise e unless options[:if_exists]
|
260
|
+
ensure
|
261
|
+
clear_table_columns_cache(table_name)
|
251
262
|
end
|
252
263
|
|
253
264
|
def insert_versions_sql(versions) # :nodoc:
|
@@ -398,6 +409,8 @@ module ActiveRecord
|
|
398
409
|
execute add_column_sql
|
399
410
|
create_sequence_and_trigger(table_name, options) if type && type.to_sym == :primary_key
|
400
411
|
change_column_comment(table_name, column_name, options[:comment]) if options.key?(:comment)
|
412
|
+
ensure
|
413
|
+
clear_table_columns_cache(table_name)
|
401
414
|
end
|
402
415
|
|
403
416
|
def aliased_types(name, fallback)
|
@@ -407,6 +420,8 @@ module ActiveRecord
|
|
407
420
|
def change_column_default(table_name, column_name, default_or_changes) #:nodoc:
|
408
421
|
default = extract_new_default_value(default_or_changes)
|
409
422
|
execute "ALTER TABLE #{quote_table_name(table_name)} MODIFY #{quote_column_name(column_name)} DEFAULT #{quote(default)}"
|
423
|
+
ensure
|
424
|
+
clear_table_columns_cache(table_name)
|
410
425
|
end
|
411
426
|
|
412
427
|
def change_column_null(table_name, column_name, null, default = nil) #:nodoc:
|
@@ -439,15 +454,21 @@ module ActiveRecord
|
|
439
454
|
execute(change_column_sql)
|
440
455
|
|
441
456
|
change_column_comment(table_name, column_name, options[:comment]) if options.key?(:comment)
|
457
|
+
ensure
|
458
|
+
clear_table_columns_cache(table_name)
|
442
459
|
end
|
443
460
|
|
444
461
|
def rename_column(table_name, column_name, new_column_name) #:nodoc:
|
445
462
|
execute "ALTER TABLE #{quote_table_name(table_name)} RENAME COLUMN #{quote_column_name(column_name)} to #{quote_column_name(new_column_name)}"
|
446
463
|
rename_column_indexes(table_name, column_name, new_column_name)
|
464
|
+
ensure
|
465
|
+
clear_table_columns_cache(table_name)
|
447
466
|
end
|
448
467
|
|
449
468
|
def remove_column(table_name, column_name, type = nil, options = {}) #:nodoc:
|
450
469
|
execute "ALTER TABLE #{quote_table_name(table_name)} DROP COLUMN #{quote_column_name(column_name)} CASCADE CONSTRAINTS"
|
470
|
+
ensure
|
471
|
+
clear_table_columns_cache(table_name)
|
451
472
|
end
|
452
473
|
|
453
474
|
def change_table_comment(table_name, comment)
|
@@ -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
|
#
|
@@ -212,6 +214,8 @@ module ActiveRecord
|
|
212
214
|
super(connection, logger, config)
|
213
215
|
@statements = StatementPool.new(self.class.type_cast_config_to_integer(config[:statement_limit]))
|
214
216
|
@enable_dbms_output = false
|
217
|
+
@do_not_prefetch_primary_key = {}
|
218
|
+
@columns_cache = {}
|
215
219
|
end
|
216
220
|
|
217
221
|
ADAPTER_NAME = "OracleEnhanced".freeze
|
@@ -427,8 +431,11 @@ module ActiveRecord
|
|
427
431
|
def prefetch_primary_key?(table_name = nil)
|
428
432
|
return true if table_name.nil?
|
429
433
|
table_name = table_name.to_s
|
430
|
-
|
431
|
-
do_not_prefetch
|
434
|
+
do_not_prefetch = @do_not_prefetch_primary_key[table_name]
|
435
|
+
if do_not_prefetch.nil?
|
436
|
+
owner, desc_table_name, db_link = @connection.describe(table_name)
|
437
|
+
@do_not_prefetch_primary_key [table_name] = do_not_prefetch = !has_primary_key?(table_name, owner, desc_table_name, db_link) || has_primary_key_trigger?(table_name, owner, desc_table_name, db_link)
|
438
|
+
end
|
432
439
|
!do_not_prefetch
|
433
440
|
end
|
434
441
|
|
@@ -514,7 +521,7 @@ module ActiveRecord
|
|
514
521
|
def column_definitions(table_name)
|
515
522
|
(owner, desc_table_name, db_link) = @connection.describe(table_name)
|
516
523
|
|
517
|
-
select_all(<<-SQL.strip.gsub(/\s+/, " "), "Column definitions"
|
524
|
+
select_all(<<-SQL.strip.gsub(/\s+/, " "), "Column definitions")
|
518
525
|
SELECT cols.column_name AS name, cols.data_type AS sql_type,
|
519
526
|
cols.data_default, cols.nullable, cols.virtual_column, cols.hidden_column,
|
520
527
|
cols.data_type_owner AS sql_type_owner,
|
@@ -527,8 +534,8 @@ module ActiveRecord
|
|
527
534
|
DECODE(data_type, 'NUMBER', data_scale, NULL) AS scale,
|
528
535
|
comments.comments as column_comment
|
529
536
|
FROM all_tab_cols#{db_link} cols, all_col_comments#{db_link} comments
|
530
|
-
WHERE cols.owner =
|
531
|
-
AND cols.table_name =
|
537
|
+
WHERE cols.owner = '#{owner}'
|
538
|
+
AND cols.table_name = #{quote(desc_table_name)}
|
532
539
|
AND cols.hidden_column = 'NO'
|
533
540
|
AND cols.owner = comments.owner
|
534
541
|
AND cols.table_name = comments.table_name
|
@@ -537,24 +544,28 @@ module ActiveRecord
|
|
537
544
|
SQL
|
538
545
|
end
|
539
546
|
|
547
|
+
def clear_table_columns_cache(table_name)
|
548
|
+
@columns_cache[table_name.to_s] = nil
|
549
|
+
end
|
550
|
+
|
540
551
|
# Find a table's primary key and sequence.
|
541
552
|
# *Note*: Only primary key is implemented - sequence will be nil.
|
542
553
|
def pk_and_sequence_for(table_name, owner = nil, desc_table_name = nil, db_link = nil) #:nodoc:
|
543
554
|
(owner, desc_table_name, db_link) = @connection.describe(table_name) unless owner
|
544
555
|
|
545
|
-
seqs = select_values(<<-SQL.strip.gsub(/\s+/, " "), "Sequence"
|
556
|
+
seqs = select_values(<<-SQL.strip.gsub(/\s+/, " "), "Sequence")
|
546
557
|
select us.sequence_name
|
547
558
|
from all_sequences#{db_link} us
|
548
|
-
where us.sequence_owner =
|
549
|
-
and us.sequence_name =
|
559
|
+
where us.sequence_owner = '#{owner}'
|
560
|
+
and us.sequence_name = upper(#{quote(default_sequence_name(desc_table_name))})
|
550
561
|
SQL
|
551
562
|
|
552
563
|
# changed back from user_constraints to all_constraints for consistency
|
553
|
-
pks = select_values(<<-SQL.strip.gsub(/\s+/, " "), "Primary Key"
|
564
|
+
pks = select_values(<<-SQL.strip.gsub(/\s+/, " "), "Primary Key")
|
554
565
|
SELECT cc.column_name
|
555
566
|
FROM all_constraints#{db_link} c, all_cons_columns#{db_link} cc
|
556
|
-
WHERE c.owner =
|
557
|
-
AND c.table_name =
|
567
|
+
WHERE c.owner = '#{owner}'
|
568
|
+
AND c.table_name = #{quote(desc_table_name)}
|
558
569
|
AND c.constraint_type = 'P'
|
559
570
|
AND cc.owner = c.owner
|
560
571
|
AND cc.constraint_name = c.constraint_name
|
@@ -31,15 +31,15 @@ describe "OracleEnhancedAdapter establish connection" do
|
|
31
31
|
expect(ActiveRecord::Base.connection).to be_active
|
32
32
|
end
|
33
33
|
|
34
|
-
it "should use database default cursor_sharing parameter value
|
34
|
+
it "should use database default cursor_sharing parameter value force by default" do
|
35
35
|
# Use `SYSTEM_CONNECTION_PARAMS` to query v$parameter
|
36
36
|
ActiveRecord::Base.establish_connection(SYSTEM_CONNECTION_PARAMS)
|
37
|
-
expect(ActiveRecord::Base.connection.select_value("select value from v$parameter where name = 'cursor_sharing'")).to eq("
|
37
|
+
expect(ActiveRecord::Base.connection.select_value("select value from v$parameter where name = 'cursor_sharing'")).to eq("FORCE")
|
38
38
|
end
|
39
39
|
|
40
|
-
it "should use modified cursor_sharing value
|
41
|
-
ActiveRecord::Base.establish_connection(SYSTEM_CONNECTION_PARAMS.merge(cursor_sharing: :
|
42
|
-
expect(ActiveRecord::Base.connection.select_value("select value from v$parameter where name = 'cursor_sharing'")).to eq("
|
40
|
+
it "should use modified cursor_sharing value exact" do
|
41
|
+
ActiveRecord::Base.establish_connection(SYSTEM_CONNECTION_PARAMS.merge(cursor_sharing: :exact))
|
42
|
+
expect(ActiveRecord::Base.connection.select_value("select value from v$parameter where name = 'cursor_sharing'")).to eq("EXACT")
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -122,6 +122,34 @@ describe "OracleEnhancedConnection" do
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
+
if defined?(OCI8)
|
126
|
+
describe "with TCP keepalive parameters" do
|
127
|
+
it "should use database default `tcp_keepalive` value true by default" do
|
128
|
+
ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection.create(CONNECTION_PARAMS)
|
129
|
+
|
130
|
+
expect(OCI8.properties[:tcp_keepalive]).to be true
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should use modified `tcp_keepalive` value false" do
|
134
|
+
ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection.create(CONNECTION_PARAMS.dup.merge(tcp_keepalive: false))
|
135
|
+
|
136
|
+
expect(OCI8.properties[:tcp_keepalive]).to be false
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should use database default `tcp_keepalive_time` value 600 by default" do
|
140
|
+
ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection.create(CONNECTION_PARAMS)
|
141
|
+
|
142
|
+
expect(OCI8.properties[:tcp_keepalive_time]).to eq(600)
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should use modified `tcp_keepalive_time` value 3000" do
|
146
|
+
ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection.create(CONNECTION_PARAMS.dup.merge(tcp_keepalive_time: 3000))
|
147
|
+
|
148
|
+
expect(OCI8.properties[:tcp_keepalive_time]).to eq(3000)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
125
153
|
describe "with non-string parameters" do
|
126
154
|
before(:all) do
|
127
155
|
params = CONNECTION_PARAMS.dup
|
@@ -381,7 +409,7 @@ describe "OracleEnhancedConnection" do
|
|
381
409
|
ActiveRecord::Base.connection.auto_retry = false
|
382
410
|
kill_current_session
|
383
411
|
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
|
384
|
-
expect { @conn.exec("SELECT * FROM dual") }.to raise_error(
|
412
|
+
expect { @conn.exec("SELECT * FROM dual") }.to raise_error(Java::JavaSql::SQLRecoverableException)
|
385
413
|
else
|
386
414
|
expect { @conn.exec("SELECT * FROM dual") }.to raise_error(OCIError)
|
387
415
|
end
|
@@ -399,7 +427,7 @@ describe "OracleEnhancedConnection" do
|
|
399
427
|
ActiveRecord::Base.connection.auto_retry = false
|
400
428
|
kill_current_session
|
401
429
|
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
|
402
|
-
expect { @conn.select("SELECT * FROM dual") }.to raise_error(
|
430
|
+
expect { @conn.select("SELECT * FROM dual") }.to raise_error(Java::JavaSql::SQLRecoverableException)
|
403
431
|
else
|
404
432
|
expect { @conn.select("SELECT * FROM dual") }.to raise_error(OCIError)
|
405
433
|
end
|
@@ -67,15 +67,16 @@ describe "OracleEnhancedAdapter" do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should get columns from database at first time" do
|
70
|
+
@conn.clear_table_columns_cache(:test_employees)
|
70
71
|
expect(TestEmployee.connection.columns("test_employees").map(&:name)).to eq(@column_names)
|
71
72
|
expect(@logger.logged(:debug).last).to match(/select .* from all_tab_cols/im)
|
72
73
|
end
|
73
74
|
|
74
|
-
it "should get columns from database at second time" do
|
75
|
+
it "should not get columns from database at second time" do
|
75
76
|
TestEmployee.connection.columns("test_employees")
|
76
77
|
@logger.clear(:debug)
|
77
78
|
expect(TestEmployee.connection.columns("test_employees").map(&:name)).to eq(@column_names)
|
78
|
-
expect(@logger.logged(:debug).last).
|
79
|
+
expect(@logger.logged(:debug).last).not_to match(/select .* from all_tab_cols/im)
|
79
80
|
end
|
80
81
|
|
81
82
|
it "should get primary key from database at first time" do
|
@@ -96,6 +97,14 @@ describe "OracleEnhancedAdapter" do
|
|
96
97
|
expect(TestEmployee2.columns.map(&:sql_type)).to eq(@column_sql_types)
|
97
98
|
end
|
98
99
|
end
|
100
|
+
|
101
|
+
it "should get sequence value at next time" do
|
102
|
+
TestEmployee.create!
|
103
|
+
expect(@logger.logged(:debug).first).not_to match(/SELECT \"TEST_EMPLOYEES_SEQ\".NEXTVAL FROM dual/im)
|
104
|
+
@logger.clear(:debug)
|
105
|
+
TestEmployee.create!
|
106
|
+
expect(@logger.logged(:debug).first).to match(/SELECT \"TEST_EMPLOYEES_SEQ\".NEXTVAL FROM dual/im)
|
107
|
+
end
|
99
108
|
end
|
100
109
|
end
|
101
110
|
|
@@ -129,6 +138,7 @@ describe "OracleEnhancedAdapter" do
|
|
129
138
|
@conn.execute "DROP DATABASE LINK #{@db_link}" rescue nil
|
130
139
|
@sys_conn.drop_table :test_posts, if_exists: true
|
131
140
|
Object.send(:remove_const, "TestPost") rescue nil
|
141
|
+
@conn.clear_table_columns_cache(:test_posts)
|
132
142
|
ActiveRecord::Base.clear_cache!
|
133
143
|
end
|
134
144
|
|
@@ -524,7 +534,7 @@ describe "OracleEnhancedAdapter" do
|
|
524
534
|
it "should return array from indexes with bind usage" do
|
525
535
|
expect(@conn.indexes("TEST_POSTS").class).to eq Array
|
526
536
|
expect(@logger.logged(:debug).last).to match(/:owner/)
|
527
|
-
expect(@logger.logged(:debug).last).to match(/\[\["owner", "#{DATABASE_USER.upcase}"\], \["owner", "#{DATABASE_USER.upcase}"\]\]/)
|
537
|
+
expect(@logger.logged(:debug).last).to match(/\[\["owner", "#{DATABASE_USER.upcase}"\], \["owner", "#{DATABASE_USER.upcase}"\], \["table_name", "TEST_POSTS"\]\]/)
|
528
538
|
end
|
529
539
|
|
530
540
|
it "should not have primary key trigger with bind usage" do
|
@@ -534,17 +544,17 @@ describe "OracleEnhancedAdapter" do
|
|
534
544
|
expect(@logger.logged(:debug).last).to match(/\[\["owner", "#{DATABASE_USER.upcase}"\], \["trigger_name", "TEST_POSTS_PKT"\], \["owner", "#{DATABASE_USER.upcase}"\], \["table_name", "TEST_POSTS"\]\]/)
|
535
545
|
end
|
536
546
|
|
537
|
-
it "should return content from columns
|
547
|
+
it "should return content from columns without bind usage" do
|
538
548
|
expect(@conn.columns("TEST_POSTS").length).to be > 0
|
539
|
-
expect(@logger.logged(:debug).last).
|
540
|
-
expect(@logger.logged(:debug).last).
|
541
|
-
expect(@logger.logged(:debug).last).
|
549
|
+
expect(@logger.logged(:debug).last).not_to match(/:owner/)
|
550
|
+
expect(@logger.logged(:debug).last).not_to match(/:table_name/)
|
551
|
+
expect(@logger.logged(:debug).last).not_to match(/\[\["owner", "#{DATABASE_USER.upcase}"\], \["table_name", "TEST_POSTS"\]\]/)
|
542
552
|
end
|
543
553
|
|
544
|
-
it "should return pk and sequence from pk_and_sequence_for
|
554
|
+
it "should return pk and sequence from pk_and_sequence_for without bind usage" do
|
545
555
|
expect(@conn.pk_and_sequence_for("TEST_POSTS").length).to eq 2
|
546
|
-
expect(@logger.logged(:debug).last).
|
547
|
-
expect(@logger.logged(:debug).last).
|
556
|
+
expect(@logger.logged(:debug).last).not_to match(/:owner/)
|
557
|
+
expect(@logger.logged(:debug).last).not_to match(/\[\["owner", "#{DATABASE_USER.upcase}"\], \["table_name", "TEST_POSTS"\]\]/)
|
548
558
|
end
|
549
559
|
|
550
560
|
it "should return pk from primary_keys with bind usage" 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: 5.2.
|
4
|
+
version: 5.2.8
|
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: 2019-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -133,37 +133,36 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
133
|
- !ruby/object:Gem::Version
|
134
134
|
version: 1.8.11
|
135
135
|
requirements: []
|
136
|
-
|
137
|
-
rubygems_version: 2.7.6
|
136
|
+
rubygems_version: 3.1.2
|
138
137
|
signing_key:
|
139
138
|
specification_version: 4
|
140
139
|
summary: Oracle enhanced adapter for ActiveRecord
|
141
140
|
test_files:
|
142
|
-
- spec/
|
143
|
-
- spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb
|
144
|
-
- spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb
|
145
|
-
- spec/active_record/connection_adapters/oracle_enhanced/database_tasks_spec.rb
|
146
|
-
- spec/active_record/connection_adapters/oracle_enhanced/schema_dumper_spec.rb
|
147
|
-
- spec/active_record/connection_adapters/oracle_enhanced/structure_dump_spec.rb
|
148
|
-
- spec/active_record/connection_adapters/oracle_enhanced/quoting_spec.rb
|
149
|
-
- spec/active_record/connection_adapters/oracle_enhanced/context_index_spec.rb
|
150
|
-
- spec/active_record/connection_adapters/oracle_enhanced/procedures_spec.rb
|
151
|
-
- spec/active_record/connection_adapters/oracle_enhanced/schema_statements_spec.rb
|
152
|
-
- spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb
|
153
|
-
- spec/active_record/connection_adapters/oracle_enhanced/dbms_output_spec.rb
|
141
|
+
- spec/spec_helper.rb
|
154
142
|
- spec/active_record/oracle_enhanced/type/integer_spec.rb
|
155
|
-
- spec/active_record/oracle_enhanced/type/national_character_text_spec.rb
|
156
|
-
- spec/active_record/oracle_enhanced/type/timestamp_spec.rb
|
157
|
-
- spec/active_record/oracle_enhanced/type/binary_spec.rb
|
158
|
-
- spec/active_record/oracle_enhanced/type/national_character_string_spec.rb
|
159
143
|
- spec/active_record/oracle_enhanced/type/raw_spec.rb
|
160
144
|
- spec/active_record/oracle_enhanced/type/float_spec.rb
|
145
|
+
- spec/active_record/oracle_enhanced/type/boolean_spec.rb
|
161
146
|
- spec/active_record/oracle_enhanced/type/dirty_spec.rb
|
147
|
+
- spec/active_record/oracle_enhanced/type/binary_spec.rb
|
148
|
+
- spec/active_record/oracle_enhanced/type/timestamp_spec.rb
|
149
|
+
- spec/active_record/oracle_enhanced/type/national_character_text_spec.rb
|
162
150
|
- spec/active_record/oracle_enhanced/type/json_spec.rb
|
163
151
|
- spec/active_record/oracle_enhanced/type/text_spec.rb
|
164
|
-
- spec/active_record/oracle_enhanced/type/
|
165
|
-
- spec/
|
166
|
-
- spec/
|
167
|
-
- spec/
|
152
|
+
- spec/active_record/oracle_enhanced/type/national_character_string_spec.rb
|
153
|
+
- spec/active_record/connection_adapters/oracle_enhanced/context_index_spec.rb
|
154
|
+
- spec/active_record/connection_adapters/oracle_enhanced/quoting_spec.rb
|
155
|
+
- spec/active_record/connection_adapters/oracle_enhanced/dbms_output_spec.rb
|
156
|
+
- spec/active_record/connection_adapters/oracle_enhanced/schema_dumper_spec.rb
|
157
|
+
- spec/active_record/connection_adapters/oracle_enhanced/procedures_spec.rb
|
158
|
+
- spec/active_record/connection_adapters/oracle_enhanced/structure_dump_spec.rb
|
159
|
+
- spec/active_record/connection_adapters/oracle_enhanced/database_tasks_spec.rb
|
160
|
+
- spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb
|
161
|
+
- spec/active_record/connection_adapters/oracle_enhanced/schema_statements_spec.rb
|
162
|
+
- spec/active_record/connection_adapters/emulation/oracle_adapter_spec.rb
|
163
|
+
- spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb
|
164
|
+
- spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb
|
168
165
|
- spec/support/alter_system_user_password.sql
|
166
|
+
- spec/support/create_oracle_enhanced_users.sql
|
169
167
|
- spec/support/alter_system_set_open_cursors.sql
|
168
|
+
- spec/spec_config.yaml.template
|