From 3bb9388c885eedc9afb9c483facbaa5b5c0c61fd Mon Sep 17 00:00:00 2001 From: Yasuo Honda Date: Wed, 31 Mar 2021 11:13:35 +0900 Subject: [PATCH 1/2] Merge pull request #2151 from yahonda/fix2139 Address `FrozenError (can't modify frozen Hash):` error --- .../connection_adapters/oracle_enhanced/jdbc_connection.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb b/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb index 3f227a5af..a65a4d815 100644 --- a/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +++ b/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb @@ -98,6 +98,8 @@ def new_connection(config) @raw_connection = @raw_connection.underlying_connection end + # Workaround FrozenError (can't modify frozen Hash): + config = config.dup config[:driver] ||= @raw_connection.meta_data.connection.java_class.name username = @raw_connection.meta_data.user_name else From f1f447152117904dae614c74f88a362d9a135559 Mon Sep 17 00:00:00 2001 From: Yasuo Honda Date: Wed, 31 Mar 2021 11:31:03 +0900 Subject: [PATCH 2/2] Address RuboCop offenses The offense itself has been fixed by https://github.com/rsim/oracle-enhanced/commit/d105887e3881672739958b0b08a0d850466c5e29 at master branch. `git cherry-pick d105887e3881672739958b0b08a0d850466c5e29` conflics then executed `bundle exec rubocop -a` for release61 branch. ``` $ bundle exec rubocop -v 1.12.0 $ bundle exec rubocop -a Inspecting 70 files ...................W.................................................. Offenses: lib/active_record/connection_adapters/oracle_enhanced/quoting.rb:13:52: C: [Corrected] Style/RedundantBegin: Redundant begin block detected. self.class.quoted_column_names[name] ||= begin ^^^^^ lib/active_record/connection_adapters/oracle_enhanced/quoting.rb:14:11: C: [Corrected] Layout/IndentationWidth: Use 2 (not 4) spaces for indentation. "\"#{name.upcase}\"" ^^^^ lib/active_record/connection_adapters/oracle_enhanced/quoting.rb:15:13: C: [Corrected] Layout/ElseAlignment: Align else with self.class.quoted_column_names[name]. else ^^^^ lib/active_record/connection_adapters/oracle_enhanced/quoting.rb:16:15: C: [Corrected] Layout/CommentIndentation: Incorrect indentation detected (column 14 instead of 12). # remove double quotes which cannot be used inside quoted identifier ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/active_record/connection_adapters/oracle_enhanced/quoting.rb:17:11: C: [Corrected] Layout/IndentationWidth: Use 2 (not 4) spaces for indentation. "\"#{name.gsub('"', '')}\"" ^^^^ lib/active_record/connection_adapters/oracle_enhanced/quoting.rb:18:13: W: [Corrected] Layout/EndAlignment: end at 18, 12 is not aligned with self.class.quoted_column_names[name] ||= if at 13, 10. end ^^^ lib/active_record/connection_adapters/oracle_enhanced/quoting.rb:19:1: C: [Corrected] Layout/EmptyLinesAroundMethodBody: Extra empty line detected at method body end. lib/active_record/connection_adapters/oracle_enhanced/quoting.rb:19:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. 70 files inspected, 8 offenses detected, 8 offenses corrected Tip: Based on detected gems, the following RuboCop extension libraries might be helpful: * rubocop-rake (https://github.com/rubocop/rubocop-rake) * rubocop-rspec (https://github.com/rubocop/rubocop-rspec) You can opt out of this message by adding the following to your config (see https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions for more options): AllCops: SuggestExtensions: false $ ``` --- .../connection_adapters/oracle_enhanced/quoting.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb b/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb index 5907a266e..a4d2c420f 100644 --- a/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +++ b/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb @@ -10,14 +10,11 @@ module Quoting def quote_column_name(name) #:nodoc: name = name.to_s - self.class.quoted_column_names[name] ||= begin - # if only valid lowercase column characters in name - if /\A[a-z][a-z_0-9\$#]*\Z/.match?(name) - "\"#{name.upcase}\"" - else - # remove double quotes which cannot be used inside quoted identifier - "\"#{name.gsub('"', '')}\"" - end + self.class.quoted_column_names[name] ||= if /\A[a-z][a-z_0-9\$#]*\Z/.match?(name) + "\"#{name.upcase}\"" + else + # remove double quotes which cannot be used inside quoted identifier + "\"#{name.gsub('"', '')}\"" end end