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

not does not negate where with string argument

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.1.0.rc0
    • Affects Version/s: None
    • Component/s: Query
    • None

      Criteria#where has a string argument form, where the argument is given to the $where operator. This form does not negate itself when the where is preceded by a not.

      Mongoid 7.0:

      irb(main):011:0> Band.not.where('hello world')
      => #<Mongoid::Criteria
        selector: {"$where"=>"hello world"}
        options:  {}
        class:    Band
        embedded: false>
      

      Expected behavior:

      irb(main):001:0> Band.not.where('hello world')
      => #<Mongoid::Criteria
        selector: {"$and"=>[{"$nor"=>[{"$where"=>"hello world"}]}]}
        options:  {}
        class:    Band
        embedded: false>
      

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: