mongomock
mongomock copied to clipboard
Small library for mocking pymongo collection objects for testing purposes
Fixes #745. This allows the use of UUID in pymongo4. Passes unit tests.
Mongo supports `$size` as a projection operator, for example in the following query: ``` db.my_collection.find({}, {"the_count": {$size:"$my_field"}}) ``` As far as I know the only supported projection operators in mongomock...
I am getting intermittent Key Errors when I use mongomock with a TTL index. I have a simple find call, like so: ``` docs = list(db.find(match, projection, limit, sort)) ```...
Parameter partialFilterExpression is [not added](https://github.com/mongomock/mongomock/blob/develop/mongomock/collection.py#L1540) to newly created index in mocked collection: ```python def create_indexes(self, indexes, session=None): # ... return [ self.create_index( index.document['key'].items(), session=session, expireAfterSeconds=index.document.get('expireAfterSeconds'), unique=index.document.get('unique', False), sparse=index.document.get('sparse', False), name=index.document.get('name'))...
Parameter partialFilterExpression is [not added](https://github.com/mongomock/mongomock/blob/develop/mongomock/collection.py#L1540) to newly created index in mocked collection: ```python def create_indexes(self, indexes, session=None): # ... return [ self.create_index( index.document['key'].items(), session=session, expireAfterSeconds=index.document.get('expireAfterSeconds'), unique=index.document.get('unique', False), sparse=index.document.get('sparse', False), name=index.document.get('name'))...
This PR supports the '$dateFromParts' (constructs and returns a Date object given the date's constituent properties) aggregation command.
… value of an empty list
Hi Mongomock team, When a projection is applied that only contains projection operators (like `$slice`), mongomock incorrectly drops all other fields except `_id`. ```python import mongomock collection = mongomock.MongoClient().db.collection collection.insert_one({...
As of `pymongo` v4+, it should error if used with default representation (Unspecified). We could implement a first feature that accepts custom representation, and only fails (NotImplementedError) if writing/reading/comparing in...
When using the positional $ operator to update multiple properties in an array of nested objects if you supply different levels of object nesting it will only take the first...