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

query by id field (not _id) performs the search on _id

    • Type: Icon: Task Task
    • Resolution: Done
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • None

      On mongoid 3 master

      Assuming I have a collection that has this document:

      { "_id" : ObjectId("4eccf9abaa673bf4c07ef0e1"), "id" : "69199", "some_field" : "80570", "name" : "Shaw Direct SNCAN"}

      Querying using where(id: '69199') or where('id'=>'69199') now preforms the query on the _id field:

      MOPED: localhost:27017 QUERY database=main collection=sources selector=

      {"_id"=>"69199"}

      flags=[:slave_ok] limit=-1 skip=0 fields=nil (0.0ms)

      Unfortunately this is an external DB and I have no way to change the column name.
      It used to work fine before Moped. Is there anyway to force the query to search on id instead of on _id ?

            Assignee:
            Unassigned Unassigned
            Reporter:
            erezrazin erezrazin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: