Skip to content

Commit 8909869

Browse files
committed
Fixed default value code to work with Unicode columns
1 parent b7dc65b commit 8909869

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/active_record/connection_adapters/sqlserver_adapter.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,9 @@ def columns(table_name, name = nil)
328328
result.collect do |column_info|
329329
# Remove brackets and outer quotes (if quoted) of default value returned by db, i.e:
330330
# "(1)" => "1", "('1')" => "1", "((-1))" => "-1", "('(-1)')" => "(-1)"
331+
# Unicode strings will be prefixed with an N. Remove that too.
331332
column_info.symbolize_keys!
332-
column_info[:default_value] = column_info[:default_value].match(/\A\(+'?(.*?)'?\)+\Z/)[1] if column_info[:default_value]
333+
column_info[:default_value] = column_info[:default_value].match(/\A\(+N?'?(.*?)'?\)+\Z/)[1] if column_info[:default_value]
333334
SQLServerColumn.new(column_info)
334335
end
335336
end

0 commit comments

Comments
 (0)