From 76890327549642f9d3a98811b30d7b98ee77d85c Mon Sep 17 00:00:00 2001 From: simukappu Date: Tue, 11 Aug 2020 00:06:42 +0900 Subject: [PATCH] Fix mongoid any_of selector error in filtered_by_group scope - MONGOID-4887 --- lib/activity_notification/orm/mongoid/notification.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/activity_notification/orm/mongoid/notification.rb b/lib/activity_notification/orm/mongoid/notification.rb index ad0df64f..e6a67051 100644 --- a/lib/activity_notification/orm/mongoid/notification.rb +++ b/lib/activity_notification/orm/mongoid/notification.rb @@ -140,7 +140,9 @@ class Notification scope :filtered_by_group, ->(group) { group.present? ? where(group_id: group.id, group_type: group.class.name) : - any_of({ :group_id.exists => false, :group_type.exists => false }, { group_id: nil, group_type: nil }) + Gem::Version.new(::Mongoid::VERSION) >= Gem::Version.new('7.1.0') ? + where(:group_id.exists => false, :group_type.exists => false).or(group_id: nil, group_type: nil) : + any_of({ :group_id.exists => false, :group_type.exists => false }, { group_id: nil, group_type: nil }) } # Selects filtered notifications later than specified time.