- 
    Type:Bug 
- 
    Resolution: Fixed
- 
    Priority:Major - P3 
- 
    Affects Version/s: None
- 
    Component/s: Persistence
- 
    None
- 
    Environment:MongoDB 4.2.x
 Mongoid 7.1.1
 Mongo 2.12.1
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
Trying to delete or destroy a model with association definitions that include dependent clauses from within a transaction fails with a Mongo::Error::OperationFailure. This seems to boil down to the calling of #blank? on the relation and how #blank? is implemented https://github.com/mongodb/mongoid/blob/master/lib/mongoid/association/many.rb#L24
Since a $count operation is not allowed from within a transaction, this results in the OperationFailure exception being raised.
If it is possible to change the implementation to use #exists? instead of #count? here, it would also provide a slight performance boost as the database can return after finding the first match and isn't forced to inspect the entire collection.
- causes
- 
                    MONGOID-4947 #any? method with block given does not behave as per Enumerable -         
- Closed
 
-         
- is related to
- 
                    MONGOID-4905 Use exists? instead of count when number of documents is not needed -         
- Closed
 
-         
- 
                    MONGOID-4522 Make #any? not retrieve entire result set, like #exists? -         
- Closed
 
-         
- 
                    MONGOID-4898 Add an estimated_count method to model classes, change count to use count_documents -         
- Closed
 
-         
- 
                    MONGOID-4909 Document restrict_with_error dependent option -         
- Closed
 
-         
- links to