module Mongoid::Matcher::EqImpl
def matches?(exists, value, condition, original_operator)
def matches?(exists, value, condition, original_operator) invokes $eq, the exception message needs to handle tors. ::InvalidQuery, "Range is not supported as an argument to '#{original_operator}'" a?(Array) { |elt| condition.include?(elt) } include?(value) a comparison with Time objects, compare using millisecond precision ompare_time_by_ms ind_of?(Time) && condition.kind_of?(Time) (value, condition) e.is_a?(Array) && condition.kind_of?(Time) p do |v| ind_of?(Time) _rounded_to_millis(v) ude?(time_rounded_to_millis(condition)) condition || _a?(Array) && value.include?(condition) ondition || ?(Array) && value.include?(condition)
def time_eq?(time_a, time_b)
unexpected results.
calculations using integer math, as inexactness of floating point calculations may produce
> Because of this flooring, applications are strongly recommended to perform all time
are serialized to BSON or Extended JSON, the times are floored to the nearest millisecond.
> Times in BSON (and MongoDB) can only have millisecond precision. When Ruby Time instances
Per https://www.mongodb.com/docs/ruby-driver/current/tutorials/bson-v4/#time-instances,
def time_eq?(time_a, time_b) o_millis(time_a) == time_rounded_to_millis(time_b)
def time_rounded_to_millis(time)
def time_rounded_to_millis(time) son_to_i * 1000 + time.usec.divmod(1000).first