Skip to content

Commit

Permalink
Columns with multi-line defaults work correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
metaskills committed Nov 2, 2009
1 parent b316f53 commit 1a619a6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

MASTER

* Columns with multi-line defaults work correctly. [bfabry]


* 2.2.22 * (October 15th, 2009)
Expand Down
2 changes: 1 addition & 1 deletion lib/active_record/connection_adapters/sqlserver_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ def column_definitions(table_name)
when nil, '(null)', '(NULL)'
nil
else
match_data = ci[:default_value].match(/\A\(+N?'?(.*?)'?\)+\Z/)
match_data = ci[:default_value].match(/\A\(+N?'?(.*?)'?\)+\Z/m)
match_data ? match_data[1] : nil
end
ci[:null] = ci[:is_nullable].to_i == 1 ; ci.delete(:is_nullable)
Expand Down
5 changes: 5 additions & 0 deletions test/cases/specific_schema_test_sqlserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ class SqlServerEdgeSchema < ActiveRecord::Base; end;

class SpecificSchemaTestSqlserver < ActiveRecord::TestCase

should 'cope with multi line defaults' do
default = StringDefault.new
assert_equal "Some long default with a\nnew line.", default.string_with_multiline_default
end

should 'default strings before save' do
default = StringDefault.new
assert_equal nil, default.string_with_null_default
Expand Down
1 change: 1 addition & 0 deletions test/schema/sqlserver_specific_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
t.column :string_with_pretend_null_three, :string, :default => 'NULL'
t.column :string_with_pretend_null_four, :string, :default => '(NULL)'
t.column :string_with_pretend_paren_three, :string, :default => '(3)'
t.column :string_with_multiline_default, :string, :default => "Some long default with a\nnew line."
end

create_table :sql_server_chronics, :force => true do |t|
Expand Down

0 comments on commit 1a619a6

Please sign in to comment.