aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-11-20 11:44:31 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-11-20 11:44:31 +0000
commitcd6beacfb3f503fe28410a67f155bb4509e76819 (patch)
tree4a7e4209891581460ba91c021e40292885925088 /activerecord/lib/active_record/connection_adapters
parent6e1012fc9c7a8cf5bb510f213462a9e2cff2e085 (diff)
downloadrails-cd6beacfb3f503fe28410a67f155bb4509e76819.tar.gz
rails-cd6beacfb3f503fe28410a67f155bb4509e76819.tar.bz2
rails-cd6beacfb3f503fe28410a67f155bb4509e76819.zip
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
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rwxr-xr-xactiverecord/lib/active_record/connection_adapters/mysql_adapter.rb5
1 files changed, 3 insertions, 2 deletions
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