Skip to content

Commit bfefdcf

Browse files
committed
Provide a method to override for the quoted string prefix. Not a config because trumping this method will have drastically bad results. Fixes #124
1 parent e609ae9 commit bfefdcf

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11

22
* 3.1.1 *
33

4+
* Provide a method to override for the quoted string prefix. Not a config because trumping this method will
5+
have drastically bad results. Fixes #124
6+
47
* Allow :limit/:offset to be used with fully qualified table and column in :select.
58

69

lib/active_record/connection_adapters/sqlserver/quoting.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module Sqlserver
44
module Quoting
55

66
QUOTED_TRUE, QUOTED_FALSE = '1', '0'
7+
QUOTED_STRING_PREFIX = 'N'
78

89
def quote(value, column = nil)
910
case value
@@ -13,7 +14,7 @@ def quote(value, column = nil)
1314
elsif column && column.type == :binary
1415
column.class.string_to_binary(value)
1516
elsif value.is_utf8? || (column && column.type == :string)
16-
"N'#{quote_string(value)}'"
17+
"#{quoted_string_prefix}'#{quote_string(value)}'"
1718
else
1819
super
1920
end
@@ -31,7 +32,11 @@ def quote(value, column = nil)
3132
super
3233
end
3334
end
34-
35+
36+
def quoted_string_prefix
37+
QUOTED_STRING_PREFIX
38+
end
39+
3540
def quote_string(string)
3641
string.to_s.gsub(/\'/, "''")
3742
end

0 commit comments

Comments
 (0)