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

Driver does not respect indexes on composite keys

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Gone away
    • 1.8.0
    • 12_01_17
    • None
    • Debian linux
      ruby 1.9.3

    Description

      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?

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: