Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-4854

Backward compatibility problem with Criteria::Queryable::Selectable#where with nil argument

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 7.1.0
    • Component/s: Query
    • None
    • Environment:
      Ruby 2.7.0

      I have a 3rd party Ruby library that, prior to version 7.1, was able to call the subject method with a nil argument and receive back the results of Selectable#reset_strategies!.  Now, Selectable#where raises an exception on a nil argument, which causes my application to crash.

      I worked around my problem with a kludge that adds the following at the beginning of the version 7.1 Selectable#where function:

      if criteria == [nil]
          return self.reset_strategies!
      end

      Now my application runs fine.  However, since I don't have a deep knowledge of Mongoid and ActiveRecord internals, I have no idea if this is reasonable or not.

       

      In any case, if you can come up with a better solution, or some guidance about how the 3rd party vendor routine can get the desired result without calling Selectable#where(nil), I would appreciate it.

       

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            mike@loopvoc.com Mike Dalpee
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: