提交 3e8ab910 编写于 作者: A Aaron Patterson

column default extraction should handle newlines.

Fixes #7374
上级 8f4ee486
......@@ -380,9 +380,9 @@ def columns(table_name) #:nodoc:
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
......
......@@ -7,6 +7,14 @@ class ColumnAttributesTest < ActiveRecord::TestCase
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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册