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

_matches? should use millisecond precision when comparing Time objects

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.4.0
    • Affects Version/s: None
    • Component/s: None
    • None

      Per https://docs.mongodb.com/ruby-driver/current/tutorials/bson-v4/#time-instances,

      > Times in BSON (and MongoDB) can only have millisecond precision. When Ruby Time instances are serialized to BSON or Extended JSON, the times are floored to the nearest millisecond.
      > Because of this flooring, applications are strongly recommended to perform all time calculations using integer math, as inexactness of floating point calculations may produce unexpected results.

      Yet _matches? doesn't apply that logic, which means it can be inaccurate.

      https://github.com/mongodb/mongoid/pull/5094 should address this.

            Assignee:
            dmitry.rybakov@mongodb.com Dmitry Rybakov
            Reporter:
            jon@braze.com Jon Hyman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: