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

Can not filter by BigDecimal field

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 6.2.0, 6.4.1, 7.0.1
    • Component/s: None
    • None
    • Environment:
      Ruby 2.4
      Rails 5.1

      I have model with BigDecimal field:

      class Invoice
        field :amount, type: BigDecimal
      end

      The following test does not pass:

      let!(:invoice) { create :invoice, amount: 10.0 }
      
      subject { Invoice.where amount: { '$gt': 0 } }
      
      it { is_expected.to include invoice }

       I think that this is due to the fact that 0 converted to string "0" for query. 

      Invoice.where(amount: { '$gt': 0 }).selector
      # => {"balance"=>{"$gte"=>"0"}}

       

            Assignee:
            sam.rossi@mongodb.com Samuel Rossi (Inactive)
            Reporter:
            max_konin Maxim Konin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: