-
Type: Bug
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: 7.0.5
-
Component/s: Query
When I use Mongoid::Criteria.not future `where`s that are not chained to the `not` still use `not`
require 'mongoid' Mongoid.connect_to 'query_not_causing_weird_stuff' class Player include Mongoid::Document field :name, type: String, default: '' field :position, type: String, default: '' field :team, type: String, default: '' field :number, type: Integer end Player.delete_all Player.create!(team: 'Falcons', position: 'QB', name: 'Vidur', number: 37) Player.create!(team: 'Falcons', position: 'WR', name: 'Jonathon', number: 47) Player.create!(team: 'Falcons', position: 'LB', name: 'David', number: 22) players_on_team = Player.where(team: 'Falcons') print players_on_team.where(position: 'WR').pluck(:name) # expect ['Jonathon'] print players_on_team.not.where(position: 'WR').pluck(:name) # expect ['Vidur', 'David'] print players_on_team.where(position: 'WR').pluck(:name) # expect ['Jonathon'] actual ['Vidur', 'David']
Not sure if this has already been fixed but I couldn't find anything about it. I found this on mongoid 7.0.4 at it seems to still be a bug on 7.0.5