From cd6beacfb3f503fe28410a67f155bb4509e76819 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 20 Nov 2006 11:44:31 +0000 Subject: Test for forged '' default before it's typecast. Closes #6156. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5596 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/connection_adapters/mysql_adapter.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters') diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index 574196e351..d7668140fd 100755 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -88,8 +88,9 @@ module ActiveRecord TYPES_ALLOWING_EMPTY_STRING_DEFAULT = Set.new([:binary, :string, :text]) def initialize(name, default, sql_type = nil, null = true) + @original_default = default super - self.default = nil if missing_default_forged_as_empty_string? + @default = nil if missing_default_forged_as_empty_string? end private @@ -107,7 +108,7 @@ module ActiveRecord # Test whether the column has default '', is not null, and is not # a type allowing default ''. def missing_default_forged_as_empty_string? - !null && default == '' && !TYPES_ALLOWING_EMPTY_STRING_DEFAULT.include?(type) + !null && @original_default == '' && !TYPES_ALLOWING_EMPTY_STRING_DEFAULT.include?(type) end end -- cgit v1.2.3