Skip to content

ReactiveRecord::Collection#any? breaks cases with args/block passed in #215

Closed
@adamcreekroad

Description

@adamcreekroad

In the latest release, this method was updated to be smarter and only load the count instead of all the records. But, the case of passing args/block to this method was missed and breaks that functionality. It should now check if args/block has been passed in, and if so then call super and use normal functionality; otherwise use the optimized way of check if the count is positive:

module ReactiveRecord
  class Collection
    def any?(*args, &block)
      # If we are doing anything other than just checking if there is an object in the collection,
      # proceed to the normal behavior
      return super if args&.length&.positive? || block.present?

      # Otherwise just check the count for efficiency
      count.positive?
    end
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions