Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-518

Driver does not respect indexes on composite keys

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 12_01_17
    • Affects Version/s: 1.8.0
    • Component/s: None
    • Environment:
      Debian linux
      ruby 1.9.3

      I have a collection, the data structure:

      { "_id" :

      { "h" : NumberLong("331673610000000"), "s" : ISODate("2011-01-10T05:05:00Z") }

      , "intervals" : [ ] }

      There is an index on _id.s:
      mongos> db.readings.getIndexes()
      [
      {
      "v" : 1,
      "key" :

      { "_id" : 1 }

      ,
      "ns" : "fivemin.readings",
      "name" : "id"
      },
      {
      "v" : 1,
      "key" :

      { "_id.s" : 1 }

      ,
      "ns" : "fivemin.readings",
      "name" : "_id.s_1",
      "background" : true
      }
      ]

      in the shell I am able to query for information using this index:
      mongos> db.readings.find(

      {"_id.s": ISODate("2011-01-10T05:05:00Z")}

      ).count()
      13135

      With the ruby driver my queries return an empty set:

      db['readings'].find("_id.s" =>

      {"$gte" => start_date, "$lte" => start_date}

      ).count()
      => 0

      Is this a defect? Should I be writing the ruby query differently?

            Assignee:
            brandon.black@10gen.com Brandon Black
            Reporter:
            bbeggs@enernoc.com Brian Beggs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: