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

Evolve Time/Date into BigDecimal

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Do
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: Attributes
    • Labels:
      None

      Time/Date do not evolve into BigDecimal when querying. This is a very minor issue and unlikely to be encountered in real-world apps, but raising because I spotted it.

       

      class Band
        field :sales, type: BigDecmial
      end
      Band.create!(sales: BigDecimal(100))
      Band.where(sales: Time.at(100)).count #=> 0 incorrect!
      

      If you replace BigDecimal with Float or Integer in the above example, it works.

      Possibly a bigger issue is that the #evolve method for BigDecimal does not appear to be handling respond to #to_d, or in the case of Date/Time, something like (.to_i + .usec).to_d would need to be called.

       

            Assignee:
            Unassigned Unassigned
            Reporter:
            shields@tablecheck.com Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: