mongoid/mongoid — Issue #1394: .exists? returns false where .length > 0 for the same criteria
Author: eimermusic
Created: 2011-11-01 12:25:06+00:00
State: open

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 the latest gem version (2.2.4).