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

.exists? returns false where .length > 0 for the same criteria

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

      My second oddity of the day. There may be gremlins in my system...

      On consecutive lines (in a rake task) I have the following code:

      puts Sms.exists?(conditions:

      { message_id: "123" }

      ) #=> false
      puts Sms.where(message_id: "123").length #=> 2

      Shouldn't happen, right? This is what exists? is supposed to be used for, right? And I can't see how some odd context-change could have messed this up. Literally on consecutive lines as you see it here. I can also see the Rails log spitting out identical queries for each. All do find count using the exact same conditions.

      I am on gem version (2.2.4).

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

              Created:
              Updated:
              Resolved: