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

Query on BigDecimal field fails

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.2
    • Affects Version/s: None
    • Component/s: None
    • None

      class FlatTax
      include Mongoid::Document
      field :r, :as => :rate, :type => BigDecimal
      end

      muichkine@ubuntu:~/src/white$ rails c -e test
      Loading test environment (Rails 4.1.8)
      2.1.4 :001 > rates = FlatTax.all.entries.map(&:rate)
      => #<BigDecimal:e92dcf0,'0.0',9(18)>, #<BigDecimal:e92dc50,'0.55E-1',9(18)>, #<BigDecimal:e92dbb0,'0.21E-1',9(18)>, #<BigDecimal:e92db10,'0.196E0',9(18)>, #<BigDecimal:e92da70,'0.7E-2',9(18)>, #<BigDecimal:e92d9d0,'0.2E0',9(18)>, #<BigDecimal:e92d930,'0.5E-1',9(18)>, #<BigDecimal:e92d840,'0.1E0',9(18)>
      2.1.4 :002 > rates.map(&:to_f)
      => [0.0, 0.055, 0.021, 0.196, 0.007, 0.2, 0.05, 0.1]
      2.1.4 :003 > FlatTax.where(:rate => BigDecimal('0.1')).entries
      => []

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            muichkine Olivier Milla
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: