activerecord-oracle_enhanced-adapter 5.2.2 → 5.2.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 192b152e571ea28d6e195b9245c3bfc6ee331254a1c55bb6d7605d5da9a50b91
4
- data.tar.gz: a954652613d0ce95d24a75bc5b6784fe2750d25e37fc26448017c1c290246df0
3
+ metadata.gz: 99ba62aedd6e50d8e73857481e9571fe6d32bcf54e63ad71efb585a41ee46de3
4
+ data.tar.gz: a328430116e7ff784117e6281e6ed7be5bc3df51ea9425d49cf3304bc0730ccf
5
5
  SHA512:
6
- metadata.gz: 04cee9773aab325fcaf71454ad982538a8940846e5b9780422f1836ff7089a20d5a9e0e8439ed7ca7770ecb956701b7b05a56ecb46a6ef7d7742306926b4fe6e
7
- data.tar.gz: 1cee77e92e6f81f4c0f93c610cb6b0436ebf39a97dd14411633295b830878cb3de485e2220a15120b7fd8826d4caf1e094662d354696de83a3beff26c865ec97
6
+ metadata.gz: ec5c2229cc8ec228ae600373f107a4dd325913c7940f9668462148bda65380818ee7ac5eaf369e042c54cda30c44ad1934cd9aa0429a783c2c723869c036066b
7
+ data.tar.gz: 566e26dc8d096883fff8409fce90160706e1ae18f4e4779cd2f83ff58657f2a91f2e93ad552068717d242af38ed70403264b6b6bf1d87b7d354bf7c61f5309d9
data/History.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 5.2.3 / 2018-08-08
2
+
3
+ * Changes and bug fixes
4
+ * Introduce column cache per connection [#1744 #1750]
5
+ * Use `cursor_sharing` = force by default again [#1745 #1748]
6
+ * Add `table_name` search condition to `indexes(table_name)` method [#1747 #1749]
7
+ * Suppress warning `BigDecimal.new` is deprecated [#1742 #1743]
8
+ * Do not install bundler explicitly [#1725 #1726]
9
+ * Add `allow_railures` for jruby-head until #1737 resolved [#1739 #1740]
10
+ * CI against JRuby 9.2.0.0 [#1728 #1741]
11
+ * Do not run CI against older version of JRuby [#1741]
12
+
1
13
  ## 5.2.2 / 2018-04-28
2
14
 
3
15
  * Changes and bug fixes
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.2.2
1
+ 5.2.3
@@ -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
@@ -476,7 +476,7 @@ module ActiveRecord
476
476
  elsif d.isInt
477
477
  Integer(d.stringValue)
478
478
  else
479
- BigDecimal.new(d.stringValue)
479
+ BigDecimal(d.stringValue)
480
480
  end
481
481
  when :BINARY_FLOAT
482
482
  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.new(value.to_s))
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
@@ -295,7 +295,7 @@ module ActiveRecord
295
295
  privilege = config[:privilege] && config[:privilege].to_sym
296
296
  async = config[:allow_concurrency]
297
297
  prefetch_rows = config[:prefetch_rows] || 100
298
- cursor_sharing = config[:cursor_sharing]
298
+ cursor_sharing = config[:cursor_sharing] || "force"
299
299
  # get session time_zone from configuration or from TZ environment variable
300
300
  time_zone = config[:time_zone] || ENV["TZ"]
301
301
 
@@ -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)
@@ -213,6 +213,7 @@ module ActiveRecord
213
213
  @statements = StatementPool.new(self.class.type_cast_config_to_integer(config[:statement_limit]))
214
214
  @enable_dbms_output = false
215
215
  @do_not_prefetch_primary_key = {}
216
+ @columns_cache = {}
216
217
  end
217
218
 
218
219
  ADAPTER_NAME = "OracleEnhanced".freeze
@@ -541,6 +542,10 @@ module ActiveRecord
541
542
  SQL
542
543
  end
543
544
 
545
+ def clear_table_columns_cache(table_name)
546
+ @columns_cache[table_name.to_s] = nil
547
+ end
548
+
544
549
  # Find a table's primary key and sequence.
545
550
  # *Note*: Only primary key is implemented - sequence will be nil.
546
551
  def pk_and_sequence_for(table_name, owner = nil, desc_table_name = nil, db_link = nil) #:nodoc:
@@ -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 exact by default" do
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("EXACT")
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 force" do
41
- ActiveRecord::Base.establish_connection(SYSTEM_CONNECTION_PARAMS.merge(cursor_sharing: :force))
42
- expect(ActiveRecord::Base.connection.select_value("select value from v$parameter where name = 'cursor_sharing'")).to eq("FORCE")
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
 
@@ -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).to match(/select .* from all_tab_cols/im)
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
@@ -137,6 +138,7 @@ describe "OracleEnhancedAdapter" do
137
138
  @conn.execute "DROP DATABASE LINK #{@db_link}" rescue nil
138
139
  @sys_conn.drop_table :test_posts, if_exists: true
139
140
  Object.send(:remove_const, "TestPost") rescue nil
141
+ @conn.clear_table_columns_cache(:test_posts)
140
142
  ActiveRecord::Base.clear_cache!
141
143
  end
142
144
 
@@ -532,7 +534,7 @@ describe "OracleEnhancedAdapter" do
532
534
  it "should return array from indexes with bind usage" do
533
535
  expect(@conn.indexes("TEST_POSTS").class).to eq Array
534
536
  expect(@logger.logged(:debug).last).to match(/:owner/)
535
- 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"\]\]/)
536
538
  end
537
539
 
538
540
  it "should not have primary key trigger with bind usage" do
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.2
4
+ version: 5.2.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: 2018-04-27 00:00:00.000000000 Z
11
+ date: 2018-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -139,31 +139,31 @@ signing_key:
139
139
  specification_version: 4
140
140
  summary: Oracle enhanced adapter for ActiveRecord
141
141
  test_files:
142
- - spec/active_record/connection_adapters/emulation/oracle_adapter_spec.rb
142
+ - spec/support/alter_system_set_open_cursors.sql
143
+ - spec/support/alter_system_user_password.sql
144
+ - spec/support/create_oracle_enhanced_users.sql
145
+ - spec/spec_config.yaml.template
143
146
  - spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb
147
+ - spec/active_record/connection_adapters/emulation/oracle_adapter_spec.rb
144
148
  - 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
149
+ - spec/active_record/connection_adapters/oracle_enhanced/dbms_output_spec.rb
147
150
  - 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_dumper_spec.rb
152
+ - spec/active_record/connection_adapters/oracle_enhanced/database_tasks_spec.rb
151
153
  - spec/active_record/connection_adapters/oracle_enhanced/schema_statements_spec.rb
154
+ - spec/active_record/connection_adapters/oracle_enhanced/procedures_spec.rb
155
+ - spec/active_record/connection_adapters/oracle_enhanced/context_index_spec.rb
156
+ - spec/active_record/connection_adapters/oracle_enhanced/quoting_spec.rb
152
157
  - spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb
153
- - spec/active_record/connection_adapters/oracle_enhanced/dbms_output_spec.rb
154
- - spec/active_record/oracle_enhanced/type/integer_spec.rb
155
- - spec/active_record/oracle_enhanced/type/national_character_text_spec.rb
156
158
  - spec/active_record/oracle_enhanced/type/timestamp_spec.rb
159
+ - spec/active_record/oracle_enhanced/type/boolean_spec.rb
160
+ - spec/active_record/oracle_enhanced/type/float_spec.rb
157
161
  - spec/active_record/oracle_enhanced/type/binary_spec.rb
158
162
  - spec/active_record/oracle_enhanced/type/national_character_string_spec.rb
163
+ - spec/active_record/oracle_enhanced/type/integer_spec.rb
159
164
  - spec/active_record/oracle_enhanced/type/raw_spec.rb
160
- - spec/active_record/oracle_enhanced/type/float_spec.rb
161
- - spec/active_record/oracle_enhanced/type/dirty_spec.rb
162
165
  - spec/active_record/oracle_enhanced/type/json_spec.rb
166
+ - spec/active_record/oracle_enhanced/type/national_character_text_spec.rb
167
+ - spec/active_record/oracle_enhanced/type/dirty_spec.rb
163
168
  - spec/active_record/oracle_enhanced/type/text_spec.rb
164
- - spec/active_record/oracle_enhanced/type/boolean_spec.rb
165
- - spec/spec_config.yaml.template
166
169
  - spec/spec_helper.rb
167
- - spec/support/create_oracle_enhanced_users.sql
168
- - spec/support/alter_system_user_password.sql
169
- - spec/support/alter_system_set_open_cursors.sql