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

BigDecimal stored as Int or Double if passed as Integer or Float

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

      I'm not sure if it is the expected behavior, but I think it's really strange :

      class Item
        include Mongoid::Document
      
        field :price, type: BigDecimal
      end
      
      Item.create price: 12
      # price is stored as an Int in MongoDB
      
      Item.create price: 12.5
      # price is stored as a Double in MongoDB
      
      Item.create price: BigDecimal.new('12.5')
      # price is stored as a String in MongoDB (as expected)
      

            Assignee:
            durran Durran Jordan
            Reporter:
            fklingler fklingler
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: