1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

column default extraction should handle newlines.

Fixes #7374
This commit is contained in:
Aaron Patterson 2012-08-17 10:21:21 -07:00
parent 8f4ee48687
commit 3e8ab910ce
2 changed files with 10 additions and 2 deletions

View file

@ -380,9 +380,9 @@ module ActiveRecord
case field["dflt_value"]
when /^null$/i
field["dflt_value"] = nil
when /^'(.*)'$/
when /^'(.*)'$/m
field["dflt_value"] = $1.gsub("''", "'")
when /^"(.*)"$/
when /^"(.*)"$/m
field["dflt_value"] = $1.gsub('""', '"')
end

View file

@ -7,6 +7,14 @@ module ActiveRecord
self.use_transactional_fixtures = false
def test_add_column_newline_default
string = "foo\nbar"
add_column 'test_models', 'command', :string, :default => string
TestModel.reset_column_information
assert_equal string, TestModel.new.command
end
def test_add_remove_single_field_using_string_arguments
refute TestModel.column_methods_hash.key?(:last_name)