-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Device.find(camera_id: nil) does not find devices #216
Comments
Hey @xanview, sorry for not replying earlier. I was on a trip and didn't have time for a proper answer. I think at some point, in earlier versions, it was possible to index |
Hi Soveran, Thank you for the reply. Sure that makes sense not to index nil by default, but maybe it could be an optional option, something like: index :device_id, index_nil: true This way you have the best of both worlds? - without resorting to hacks such as a "nil" string value. |
I explored that solution, but in the end I didn't find it satisfying. First, a bit more about my previous proposal: instead of using the string Regarding the After reflecting on this issue, I think the best approach would be to use a meaningful value for that field and rely on the existing indexing infrastructure. |
I can see what you're saying, but in terms of other databases, I'm used to doing this with Mongo (Mongoid): User.where(:auth_token.exists => false) You're right, if no index is configured, it will have to scan the entire database, but at least it gives the expected behaviour of running the requested query. Maybe it should throw an exception when searching for nil at least? - it can even link to this issue in the exception so the person has a workaround :) |
Two great ideas right there: first, raise an error if |
I'm expecting it to find the 4 devices where camera_id is nil, but it's not finding anything. Any ideas?
The text was updated successfully, but these errors were encountered: