Skip to content

Commit ae715cd

Browse files
authored
Merge pull request #2347 from yahonda/diag48773_release70
[release70] Make ActiveRecord's quoted name caches thread-safe on JRuby/TruffleRuby
2 parents 3418239 + e130d94 commit ae715cd

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/active_record/connection_adapters/oracle_enhanced/quoting.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ module Quoting
77
# QUOTING ==================================================
88
#
99
# see: abstract/quoting.rb
10+
QUOTED_COLUMN_NAMES = Concurrent::Map.new # :nodoc:
11+
QUOTED_TABLE_NAMES = Concurrent::Map.new # :nodoc:
1012

1113
def quote_column_name(name) # :nodoc:
1214
name = name.to_s
13-
self.class.quoted_column_names[name] ||= if /\A[a-z][a-z_0-9$#]*\Z/.match?(name)
15+
QUOTED_COLUMN_NAMES[name] ||= if /\A[a-z][a-z_0-9$#]*\Z/.match?(name)
1416
"\"#{name.upcase}\""
1517
else
1618
# remove double quotes which cannot be used inside quoted identifier
@@ -26,7 +28,7 @@ def quote_column_name_or_expression(name) # :nodoc:
2628
# if only valid lowercase column characters in name
2729
when /^[a-z][a-z_0-9$#]*$/
2830
"\"#{name.upcase}\""
29-
when /^[a-z][a-z_0-9$#\-]*$/i
31+
when /^[a-z][a-z_0-9$#-]*$/i
3032
"\"#{name}\""
3133
# if other characters present then assume that it is expression
3234
# which should not be quoted
@@ -67,7 +69,7 @@ def self.mixed_case?(name)
6769

6870
def quote_table_name(name) # :nodoc:
6971
name, _link = name.to_s.split("@")
70-
self.class.quoted_table_names[name] ||= [name.split(".").map { |n| quote_column_name(n) }].join(".")
72+
QUOTED_TABLE_NAMES[name] ||= [name.split(".").map { |n| quote_column_name(n) }].join(".")
7173
end
7274

7375
def quote_string(s) # :nodoc:

spec/active_record/oracle_enhanced/type/custom_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# frozen_string_literal: true
22

3+
require "base64"
4+
35
describe "OracleEnhancedAdapter custom types handling" do
46
include SchemaSpecHelper
57

0 commit comments

Comments
 (0)