Skip to content
Browse files

column default extraction should handle newlines.

Fixes #7374
  • Loading branch information...
1 parent 8f4ee48 commit 3e8ab910ce636c9980d4fd9bc9aade795fd578ef @tenderlove tenderlove committed Aug 17, 2012
View
4 activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
@@ -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
View
8 activerecord/test/cases/migration/column_attributes_test.rb
@@ -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)

0 comments on commit 3e8ab91

Please sign in to comment.
Something went wrong with that request. Please try again.