From ecadb9661998be016a8e423925d926222eabacd9 Mon Sep 17 00:00:00 2001 From: Vadim Kazakov Date: Tue, 28 Nov 2023 09:27:33 -0700 Subject: [PATCH] fix mongoid8 * 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 --- lib/bullet/mongoid8x.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/bullet/mongoid8x.rb b/lib/bullet/mongoid8x.rb index 31c538a6..f1d250dd 100644 --- a/lib/bullet/mongoid8x.rb +++ b/lib/bullet/mongoid8x.rb @@ -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