Commit d5b64c1
MONGOID-5029 #empty method should use an #exists? rather than a #count query (#5029)
* Fixes MONGOID-5029
- `#empty?` method should use an exists rather than a count query.
- `#empty?` and `#any?` should short-circuit avoid making a query if _added is set
- Make `#empty?` congruent with `#any?` code-wide
* #any? is exactly the inverse of #empty?
* Specs for empty?
* Add spec for any
* Fix all feedback from oleg
* adjust the tests since there are now fewer queries
Co-authored-by: shields <shields@tablecheck.com>
Co-authored-by: Oleg Pudeyev <code@olegp.name>1 parent e98024c commit d5b64c1
File tree
3 files changed
+253
-105
lines changed- lib/mongoid/association/referenced/has_many
- spec/mongoid/association/referenced/has_many
3 files changed
+253
-105
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
| 193 | + | |
194 | 194 | | |
195 | | - | |
| 195 | + | |
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
| 226 | + | |
231 | 227 | | |
232 | 228 | | |
233 | 229 | | |
| |||
0 commit comments