From 4913ddd7347faba3a3a34764a00d60b51f313842 Mon Sep 17 00:00:00 2001 From: Justin George Date: Thu, 29 Oct 2009 14:39:55 -0700 Subject: [PATCH] Fix record destruction failing on Bignum ids and change to using Integer some places Fixnum was used --- .../associations/association_collection.rb | 2 +- activerecord/lib/active_record/base.rb | 2 +- activerecord/lib/active_record/calculations.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index 42b6e5d..4385690 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -208,7 +208,7 @@ module ActiveRecord # Note that this method will _always_ remove records from the database # ignoring the +:dependent+ option. def destroy(*records) - records = find(records) if records.any? {|record| record.kind_of?(Fixnum) || record.kind_of?(String)} + records = find(records) if records.any? {|record| record.kind_of?(Integer) || record.kind_of?(String)} remove_records(records) do |records, old_records| old_records.each { |record| record.destroy } end diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 2ec2f73..4058877 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -3021,7 +3021,7 @@ module ActiveRecord #:nodoc: # by calling new on the column type or aggregation type (through composed_of) object with these parameters. # So having the pairs written_on(1) = "2004", written_on(2) = "6", written_on(3) = "24", will instantiate # written_on (a date type) with Date.new("2004", "6", "24"). You can also specify a typecast character in the - # parentheses to have the parameters typecasted before they're used in the constructor. Use i for Fixnum, f for Float, + # parentheses to have the parameters typecasted before they're used in the constructor. Use i for Integer, f for Float, # s for String, and a for Array. If all the values for a given attribute are empty, the attribute will be set to nil. def assign_multiparameter_attributes(pairs) execute_callstack_for_multiparameter_attributes( diff --git a/activerecord/lib/active_record/calculations.rb b/activerecord/lib/active_record/calculations.rb index eb149e8..c77a909 100644 --- a/activerecord/lib/active_record/calculations.rb +++ b/activerecord/lib/active_record/calculations.rb @@ -88,7 +88,7 @@ module ActiveRecord # Options such as :conditions, :order, :group, :having, and :joins can be passed to customize the query. # # There are two basic forms of output: - # * Single aggregate value: The single value is type cast to Fixnum for COUNT, Float for AVG, and the given column's type for everything else. + # * Single aggregate value: The single value is type cast to Integer for COUNT, Float for AVG, and the given column's type for everything else. # * Grouped values: This returns an ordered hash of the values and groups them by the :group option. It takes either a column name, or the name # of a belongs_to association. # @@ -298,7 +298,7 @@ module ActiveRecord case operation when 'count' then value.to_i when 'sum' then type_cast_using_column(value || '0', column) - when 'avg' then value && (value.is_a?(Fixnum) ? value.to_f : value).to_d + when 'avg' then value && (value.is_a?(Integer) ? value.to_f : value).to_d else type_cast_using_column(value, column) end end -- 1.6.2.2