-
Type: New Feature
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: Query
As described in https://jira.mongodb.org/browse/MONGOID-5454?focusedCommentId=4731472&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-4731472, AR tracks the default scope separately from other query conditions. We should investigate having the same behavior in Mongoid.
Of particular interest is interaction with https://jira.mongodb.org/browse/MONGOID-5214.
Original report:
Please note the following. The .nor method merges in the default scope and effectively negates it (i.e. flips its meaning). I think this is completely unexpected by users.
class Band include Mongoid::Document default_scope ->{ where(foo: 1) } end Band.all #=> <Mongoid::Criteria selector: {"foo"=>1} ... Band.nor([{name: "Tool" }]) #=> <Mongoid::Criteria selector: {"$nor"=>[{"foo"=>1}, {"name"=>"Tool"}]} # EXPECTED: #=> <Mongoid::Criteria selector: {"foo"=>1, "$nor"=>[{"name"=>"Tool"}]}
- related to
-
MONGOID-5215 Document that or/nor conditions make default scope one of the disjunction branches
- Closed
-
MONGOID-5214 Make unscoped clear current scope or document that it does not
- Closed