Skip to content

Commit

Permalink
Merge pull request #2347 from yahonda/diag48773_release70
Browse files Browse the repository at this point in the history
[release70] Make ActiveRecord's quoted name caches thread-safe on JRuby/TruffleRuby
  • Loading branch information
yahonda authored Jul 31, 2023
2 parents 3418239 + e130d94 commit ae715cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ module Quoting
# QUOTING ==================================================
#
# see: abstract/quoting.rb
QUOTED_COLUMN_NAMES = Concurrent::Map.new # :nodoc:
QUOTED_TABLE_NAMES = Concurrent::Map.new # :nodoc:

def quote_column_name(name) # :nodoc:
name = name.to_s
self.class.quoted_column_names[name] ||= if /\A[a-z][a-z_0-9$#]*\Z/.match?(name)
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
Expand All @@ -26,7 +28,7 @@ def quote_column_name_or_expression(name) # :nodoc:
# if only valid lowercase column characters in name
when /^[a-z][a-z_0-9$#]*$/
"\"#{name.upcase}\""
when /^[a-z][a-z_0-9$#\-]*$/i
when /^[a-z][a-z_0-9$#-]*$/i
"\"#{name}\""
# if other characters present then assume that it is expression
# which should not be quoted
Expand Down Expand Up @@ -67,7 +69,7 @@ def self.mixed_case?(name)

def quote_table_name(name) # :nodoc:
name, _link = name.to_s.split("@")
self.class.quoted_table_names[name] ||= [name.split(".").map { |n| quote_column_name(n) }].join(".")
QUOTED_TABLE_NAMES[name] ||= [name.split(".").map { |n| quote_column_name(n) }].join(".")
end

def quote_string(s) # :nodoc:
Expand Down
2 changes: 2 additions & 0 deletions spec/active_record/oracle_enhanced/type/custom_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require "base64"

describe "OracleEnhancedAdapter custom types handling" do
include SchemaSpecHelper

Expand Down

0 comments on commit ae715cd

Please sign in to comment.