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

$gt query behaves as $gte for timestamps with millisecond precision.

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

      In an empty db, 1 Video is created

      2.1.0 :010 > float_created_at = Video.first.created_at.to_f
      1406102520.972
      2.1.0 :012 > Video.where(:created_at.gte => float_created_at).count
      1
      2.1.0 :011 > Video.where(:created_at.gt => float_created_at).count
      1

      $gt should be 0, not 1

      This is important for example when using timestamps for pagination, where millisecond precision is necessary (ie. multiple Posts might have been created on the same second).

      Similarly $lte , in the following case should return 1, not 0

      2.1.0 :014 > Video.where(:created_at.lt => float_created_at).count
      0
      2.1.0 :015 > Video.where(:created_at.lte => float_created_at).count
      0

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            robj rob jennings
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: