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

Specifying `not` multiple times does not toggle negation state

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 9.1.0, 9.0.4, 8.1.8
    • Affects Version/s: 9.0.0, 8.1.5
    • Component/s: Query
    • Ruby Drivers
    • Not Needed

      From the GitHub forums:

      "What is expected when you use 2 not operators in sequence like User.not.not.where(field: true)? Shouldn't the query User.where(foo: true) be equivalent to User.not.not.where(foo:true)? I am finding that this is not the case, and am wondering if this usage of the not operator is unsupported or if this is a bug?"

      I've confirmed this is a bug – specifying not a second time does not toggle the criteria's negation state as it should.

      See: https://github.com/mongodb/mongoid/blob/master/lib/mongoid/criteria/queryable/selectable.rb#L556

            Assignee:
            darshana.venkatesh@mongodb.com Darshana Venkatesh
            Reporter:
            jamis.buck@mongodb.com Jamis Buck
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: