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

Atomic inc on Integer field persists a float

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

      The following code demonstrates how an atomic integer increment persists a float:

      class TestCase
        include Mongoid::Document
      
        field :int_field, :type => Integer, :default => 0
      
        def self.update_integer_field()
          _x = TestCase.create
          _x.inc(:int_field, 4)
        end
      end
      

      Incorrectly persists and returns a float in the atomic integer increment:

      1.9.3p194 :002 > TestCase.update_integer_field
       => 4 
      1.9.3p194 :003 > TestCase.last.int_field
       => 4.0 
      1.9.3p194 :006 > TestCase.last.int_field.class.name
       => "Float" 
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            digitalplaywright digitalplaywright
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: