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

Specifying `not` multiple times does not toggle negation state

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 9.0.0, 8.1.5
    • Component/s: Query
    • Ruby Drivers

      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:
            Unassigned Unassigned
            Reporter:
            jamis.buck@mongodb.com Jamis Buck
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: