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

Mongoid Criteria unexpected results when searching a document by id

      mongoid (4.0.0.beta1), rails (4.0.1), ruby (2.1.0), mongoDB (2.4.9)

      I have a Mongoid Criteria of users and I want to find a user. Given a user that I'm sure doesn't exists in the criteria:

      >> users.where(email: user.email).exists?
      => false

      >> users.map(&:id).include?(user.id)
      => false

      When I search by id I always get the user instead of nil:

      >> users.find(user.id)
      => #<User _id: 521a43b37

      >> users.where(id: user.id).first
      => #<User _id: 521a43b37

      >> users.where(_id: user.id).first
      => #<User _id: 521a43b37

      >> users.where(id: user.id).exists?
      => true

      Am I doing something wrong?

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

              Created:
              Updated:
              Resolved: