Added type conversion before saving a record, so string-based values like...

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
上级 37a46151
*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]
......
......@@ -1241,7 +1241,7 @@ def attributes_protected_by_default
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
......
......@@ -179,7 +179,7 @@ def type_cast(value)
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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册