Skip to content

Commit 13d5266

Browse files
committed
Fix quoting of non-national columns.
1 parent e928fe8 commit 13d5266

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#### Fixed
44

55
* Removed errand puts statment from database tasks.
6+
* Fix quoting of non-national columns.
67

78

89
## v4.2.14

lib/active_record/connection_adapters/sqlserver/type/char.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def initialize(value)
2121
end
2222

2323
def quoted
24-
"'#{@value}'"
24+
"'#{Utils.quote_string(@value)}'"
2525
end
2626

2727
def to_s

test/cases/specific_schema_test_sqlserver.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,16 @@ def quoted_id
125125
assert_sql(/@0 = 'T'/) { SSTestDatatypeMigration.where(varchar_col: 'T').first }
126126
end
127127

128+
it 'can update and hence properly quoted non-national char/varchar columns' do
129+
o = SSTestDatatypeMigration.create!
130+
o.varchar_col = "O'Reilly"
131+
o.save!
132+
o.reload.varchar_col.must_equal "O'Reilly"
133+
o.varchar_col = nil
134+
o.save!
135+
o.reload.varchar_col.must_be_nil
136+
end
137+
128138
# With column names that have spaces
129139

130140
it 'create record using a custom attribute reader and be able to load it back in' do

0 commit comments

Comments
 (0)