Skip to content

Commit

Permalink
fix mongoid8
Browse files Browse the repository at this point in the history
* make `first` and `last` signatures compatible with mongoid 8 see https://www.mongodb.com/docs/mongoid/current/release-notes/mongoid-8.0/#-id_sort-option-on--first-last-removed
* `first` and `last` only take a limit value rather than an option set
  • Loading branch information
yads committed Nov 28, 2023
1 parent 5de1867 commit ecadb96
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/bullet/mongoid8x.rb
Expand Up @@ -8,14 +8,14 @@ def self.enable
alias_method :origin_each, :each
alias_method :origin_eager_load, :eager_load

def first(opts = {})
result = origin_first(opts)
def first(limit = nil)
result = origin_first(limit)
Bullet::Detector::NPlusOneQuery.add_impossible_object(result) if result
result
end

def last(opts = {})
result = origin_last(opts)
def last(limit = nil)
result = origin_last(limit)
Bullet::Detector::NPlusOneQuery.add_impossible_object(result) if result
result
end
Expand Down

0 comments on commit ecadb96

Please sign in to comment.