Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-10071

Timestamp comparisons work inconsistently and queries seem to return incorrect results.

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.4.4, 2.5.0
    • Querying
    • None
    • ALL

    Description

      Depending on whether the shell saves ts as

      {t: xxx, i: x}

      or Timestamp(xxx,x) different queries return different results even though they appear the same in the shell.

      test@(2.5.0) > db.querytest.insert({ts:Timestamp(1371589951, 5)})
      Inserted 1 record(s) in 310ms
      test@(2.5.0) > db.querytest.insert({ts:{ "t" : 1371589951, "i" : 5 }})
      Inserted 1 record(s) in 1ms
      test@(2.5.0) > db.querytest.find({ts: { "$gte" : Timestamp(1371589951, 1), "$lte" : Timestamp(1371589952 , 1) } } )
      { "_id" : ObjectId("51d1bbbffce6ce6f1f87fb4e"), "ts" : Timestamp(1371589951, 5) }
      Fetched 1 record(s) in 3ms
      test@(2.5.0) > db.querytest.find({ts: { "$gte" : {t: 1371589951, i: 1}, "$lte" : {t: 1371589952 , i: 1} } } )
      { "_id" : ObjectId("51d1bbc6fce6ce6f1f87fb4f"), "ts" : { "t" : 1371589951, "i" : 5 } }
      test@(2.5.0) > db.querytest.find()
      { "_id" : ObjectId("51d1bbbffce6ce6f1f87fb4e"), "ts" : Timestamp(1371589951, 5) }
      { "_id" : ObjectId("51d1bbc6fce6ce6f1f87fb4f"), "ts" : { "t" : 1371589951, "i" : 5 } }
      Fetched 2 record(s) in 0ms

      Behaves the same in 2.5.0 and 2.4.4

      Attachments

        Activity

          People

            sverch Shaun Verch
            asya.kamsky@mongodb.com Asya Kamsky
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: