diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-20 14:25:26 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-20 14:25:26 +0000 |
commit | dabf90624932ef49214383b0e0bd7d3b80fbc39f (patch) | |
tree | 9b40743e5692e553ca04fc8ef81406544d9568de /activerecord | |
parent | 37a46151ec14ae11f5306d997b822f30be7a69d3 (diff) | |
download | rails-dabf90624932ef49214383b0e0bd7d3b80fbc39f.tar.gz rails-dabf90624932ef49214383b0e0bd7d3b80fbc39f.tar.bz2 rails-dabf90624932ef49214383b0e0bd7d3b80fbc39f.zip |
Added type conversion before saving a record, so string-based values like "10.0" arent left for the database to convert #820 [dave@cherryville.org]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@928 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/connection_adapters/abstract_adapter.rb | 2 |
3 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 089955b974..61ecb3fd16 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added type conversion before saving a record, so string-based values like "10.0" aren't left for the database to convert #820 [dave@cherryville.org] + * Added with additional settings for working with transactional fixtures and pre-loaded test databases #865 [mindel] * Fixed acts_as_list to trigger remove_from_list on destroy after the fact, not before, so a unique position can be maintained #871 [Alisdair McDiarmid] diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index f85cad1f98..a60741fc21 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1241,7 +1241,7 @@ module ActiveRecord #:nodoc: def attributes_with_quotes(include_primary_key = true) columns_hash = self.class.columns_hash - attrs_quoted = @attributes.inject({}) do |attrs_quoted, pair| + attrs_quoted = attributes.inject({}) do |attrs_quoted, pair| attrs_quoted[pair.first] = quote(pair.last, columns_hash[pair.first]) unless !include_primary_key && pair.first == self.class.primary_key attrs_quoted end diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index ac58b60e8d..0ed496ea43 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -179,7 +179,7 @@ module ActiveRecord case type when :string then value when :text then value - when :integer then value.to_i + when :integer then value.to_i rescue value ? 1 : 0 when :float then value.to_f when :datetime then string_to_time(value) when :timestamp then string_to_time(value) |