Comparison operators do not work embedded documents

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: 3.1.5
    • Component/s: Querying
    • None
    • ALL
    • Hide
      > db.t2.insert({"bef" : { "dt" : 20090401 }})
      WriteResult({ "nInserted" : 1 })
      > db.t2.find({"bef" : { "dt" : 20090401 }})
      { "_id" : ObjectId("560c32d8bb3c86325d09eead"), "bef" : { "dt" : 20090401 } }
      > db.t2.find({"bef" : { "dt" : {$lte: 20090401} }})
      > db.t2.find({"bef.dt" : {$lte: 20090401} })
      { "_id" : ObjectId("560c32d8bb3c86325d09eead"), "bef" : { "dt" : 20090401 } }
      
      Show
      > db.t2.insert({ "bef" : { "dt" : 20090401 }}) WriteResult({ "nInserted" : 1 }) > db.t2.find({ "bef" : { "dt" : 20090401 }}) { "_id" : ObjectId( "560c32d8bb3c86325d09eead" ), "bef" : { "dt" : 20090401 } } > db.t2.find({ "bef" : { "dt" : {$lte: 20090401} }}) > db.t2.find({ "bef.dt" : {$lte: 20090401} }) { "_id" : ObjectId( "560c32d8bb3c86325d09eead" ), "bef" : { "dt" : 20090401 } }
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      If you want to query embedded document, for example, "dt" of {"bef" : { "dt" : 20090401 }} and compare it with a value, simple comparison ({ "dt" : 20090401 }) will work, but $lte/$gte and other comparison operators would not

            Assignee:
            David Storch
            Reporter:
            Sveta
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: