Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2318

Float, Fixnum weirdness with update_attributes

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.0.6
    • Affects Version/s: None
    • Component/s: None

      I just noticed on Mongoid master, I have a field: pu, type: Float and if I persist data like 11.0, 12.0 with set(:pu, 11.0) is saved normally as Float, but if I try update_attributes(pu: 11.0) is saved as Fixnum, Integer.

      ruby-1.9.3-p194 > Trst::Freight.find('4e317a1713e16c0dfc000018').update_attributes(pu: 13.5)
       => true 
      ruby-1.9.3-p194 > Trst::Freight.find('4e317a1713e16c0dfc000018').pu.class
       => Float 
      ruby-1.9.3-p194 > Trst::Freight.find('4e317a1713e16c0dfc000018').update_attributes(pu: 13)
       => true 
      ruby-1.9.3-p194 > Trst::Freight.find('4e317a1713e16c0dfc000018').pu.class
       => Fixnum 
      ruby-1.9.3-p194 > Trst::Freight.find('4e317a1713e16c0dfc000018').update_attributes(pu: 13.0)
       => true 
      ruby-1.9.3-p194 > Trst::Freight.find('4e317a1713e16c0dfc000018').pu.class
       => Fixnum 
      ruby-1.9.3-p194 > Trst::Freight.find('4e317a1713e16c0dfc000018').update_attributes(pu: 13.5)
       => true 
      ruby-1.9.3-p194 > Trst::Freight.find('4e317a1713e16c0dfc000018').pu.class
       => Float 
      ruby-1.9.3-p194 > Trst::Freight.find('4e317a1713e16c0dfc000018').update_attributes(pu: 13.0)
       => true 
      ruby-1.9.3-p194 > Trst::Freight.find('4e317a1713e16c0dfc000018').pu.class
       => Fixnum 
      ruby-1.9.3-p194 > Trst::Freight.find('4e317a1713e16c0dfc000018').set(:pu,13.0)
       => 13 
      ruby-1.9.3-p194 > Trst::Freight.find('4e317a1713e16c0dfc000018').pu.class
       => Float 
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            kfl62g@gmail.com Ferenc-Lorant Kiss
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: