Skip to content

Commit

Permalink
Remove constants and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanharan committed Nov 14, 2023
1 parent 29b60cd commit 76435d4
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/active_record/connection_adapters/sqlserver/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ module ActiveRecord
module ConnectionAdapters
module SQLServer
module Utils
QUOTED_STRING_PREFIX = "N"

# Value object to return identifiers from SQL Server names http://bit.ly/1CZ3EiL
# Inspired from Rails PostgreSQL::Name adapter object in their own Utils.
#
class Name
SEPARATOR = "."
UNQUOTED_SCANNER = /\]?\./
QUOTED_SCANNER = /\A\[.*?\]\./
QUOTED_CHECKER = /\A\[/
Expand Down Expand Up @@ -42,7 +38,7 @@ def server_quoted
end

def fully_qualified_database_quoted
[server_quoted, database_quoted].compact.join(SEPARATOR)
[server_quoted, database_quoted].compact.join('.')
end

def fully_qualified?
Expand All @@ -69,7 +65,7 @@ def to_s
end

def quoted
parts.map { |p| quote(p) if p }.join SEPARATOR
parts.map { |p| quote(p) if p }.join('.')
end

def quoted_raw
Expand Down Expand Up @@ -132,15 +128,15 @@ def parts
extend self

def quote_string(s)
s.to_s.gsub /\'/, "''"
s.to_s.gsub(/\'/, "''")
end

def quote_string_single(s)
"'#{quote_string(s)}'"
end

def quote_string_single_national(s)
"#{QUOTED_STRING_PREFIX}'#{quote_string(s)}'"
"N'#{quote_string(s)}'"
end

def quoted_raw(name)
Expand Down

0 comments on commit 76435d4

Please sign in to comment.