Changelog
### 4.1.0
```
Full support (CI) of Python 3.10 and MongoDB v5.
* Add support for partialFilterExpression to create\_index (784)
* Handle $ in update operations when it is the last field. (787)
* Drop system collections on drop\_database calls. (788)
* Add support for "number" alias in $type (757)
* Allow system vars expressions to generate arrays (619)
* Handle $arrayElementAt applied to $filter
* $pushall $addToSet dollar operand support (786)
* Fix handling non existent fields and other errors in arithmetic operators and grouping. (502)
* Add support for allow\_disk\_use (780)
* Use class instead of function in patch (768)
* Make reading documents more thread safe. 694 (695)
* Patch gridfs without using isinstance. (761)
* Fix behavior for $type filter on arrays (756)
* Fix behavior for $type filter on numeric types (755)
* Make find(projection=...) return copies of the values (753)
* Add $not as a logic operator (716)
* Implement $map operator (738)
* Fix aggregation failing if index does not exists, added test (646)
* Sublist candidate handling update (676)
* Make distinct() work with arrays of dicts (751)
* Add let and array\_filters args for update\_ methods
* Create the list\_collections method on Database
* Keep a client's server info consistent
* Get the server info from an env var
* Keep the server\_info value in sync with the CI
```
### 4.0.0
```
This release mainly brings support for `pymongo` v4. It is still compatible with `pymongo` v3 and despite the major version, in most cases it should be an easy upgrade.
Breaking Changes
* Drop support for Python 2
* If no `pymongo` is installed at runtime, uses `pymongo` v4 interface
```
### 3.23.0
```
* Add default and options to get_default_database() (693)
* Bump the version of hacking, setting our flake8 config
* Support read\_concern in database.get\_collection() (708)
* Support $toLong operator (705)
* Fix for {$size: 1} queries on non-existent fields (711)
* Parse \`index\` of $arrayElemAt. Fix 607 (701)
* Implement the $let operator. (698)
* Implement the $expr operator. (538)
* Fix some bad indenting
* Fail properly on computing the $size of a missing array. (697)
* Fix SyntaxWarning about using "is not" with literals
* Add support for mergeObjects operator (689)
* fix: use group operators in addFields (690)
```
### 3.22.1
```
* Fix type stubs for patch and test it to prevent regressions
* Fix missing fields management in the graphLookup stage
* Allow dot'ted field in connectFrom of $graphLookup aggregation pipeline (686)
```
### 3.22.0
```
* Mark $convert and $toLong operators as not implemented yet
* Handle negative limit values for cursor
* Add filter kwarg to list\_collection\_names (681)
* Align equality and hashable capacity on Pymongo's object
* Really run tests for Python 3.9
* Add typing stubs
* Add the collation property to Cursor
* Add Python 3.9 to the test matrix
* Accept collation kwarg in update\_one and update\_many
* Performance improvement: create only one instance of \_Filterer (674)
* Implement '$concatArrays' aggregation pipeline operator (672)
```
### 3.21.0
```
* Return the right document for find\_one\_and\_replace using ReturnDocument.AFTER and upsert
* Implement basic codec\_options (670)
* Add $trim and $dateFromSTring to the unimplemented operators
* Stop using obsolete methods in unit tests as much as possible
* Implement boolean operators (663)
* Implement TTL Indexes (660)
* Fix pylint after v2.6.0 release
* Introduce Docker to ease local development (659)
* Implement the $regexMatch operator. (658)
* Implement the $split operator (661)
* Upgrade to MongoDB v4.4
* Create a framework to silence some NotImplementedError. (656)
* Raise an error when trying to create the same index with different options
* Raise a TypeError when creating an index with a wrong param
* Fix $elemMatch querying on values directly
* Fix $pull update operation when using $in for a nested field
* Accept snapshot or other keyword arguments for find, although raise an OperationFailure if it's not falsy
* Mark the start\_session method of MongoClient as not implemented
* Fix tz awareness for count\_documents and $match in aggregate
* Fix a test that was assuming to be run on UTC clock. (652)
```
### 3.20.0
```
* Handling truthy and falsy values the way MongoDB does it (651)
* Add support for group by DBRefs (636)
* Implement $switch operator (645)
* Add hint optional argument to bulk operations (compatibility with pymongo v3.11+)
* Mark new $regexMatch operator as not implemented
* Drop the test database rather than the test collection (601)
* Implement $pop (602)
* A little fix in the example (644)
* Mark $mergeObjects as valid but not implemented
* DOC: Clarify how to use mongomock.patch with pymongo (640)
* Add many operators from 3.4 release as NotImplemented
* Raise a WriteError when trying to update with an empty $set. (623)
* Add context mananger methods to mongomock client (633)
* Implement $arrayToObject operator (624)
* Add support for read concern (628)
* Implements $setEquals operator (596)
* Update README.rst (621)
* Support $sum decimal type of values (618)
* Compare UUID values. (616)
* Test and fix sorting between mixed types
* Fix travis config
* $addField(fix): fix the not exist case in $toInt and $toDecimal (612)
* Add $toDecimal operator (610)
* Project missing fields in a nested dict fix (605)
* Dot support for localField (603)
* Fix grammar (600)
* Mark TTL Index as not implemented
* Allow $all to be specified alongside other operators (597)
* Handle the specific case of inserting a Timestamp(0,0) to be replaced by the current time. (593)
* Add $dateToString opeartor (590)
* Support for $slice operator in projection argument (588)
```
### 3.19.0
```
* Add an easy way to compare exception types between mongomock and pymongo
* collection.py: Fix return value of Collection.documents\_count() (586)
* Type conversion (583)
* Add the new kwarg bypass\_document\_validation
* Add support for subtracting milliseconds from a date (581)
* Implement the $addFields (alias $set) stage of aggregate. (574)
* Do not modify inserted documents, except for the \_id
* Test mongomock on Python 3.8 as well
* Add raw batch BSON operations as not implemented (missing) features
* Add new aggregation pipeline stages introduced in 4.2 and mark them as not implemented
* Silent some new pyint warnings
* Raise a NotImplementedError for valid query operators that have not been implemented in Mongomock yet
* Raise an error when an aggregate expression contains more than one field. (557)
* Fix $ne on arrays
* Fix lint error detected by a new version of pylint
```
### 3.18.0
```
* Implement the $facet operator. (563)
* Fix index creation when a value used in the indexed fields is not hashable (e.g. dict)
* Support bson.regex on $not queries (560)
* Mark Cursor.count method as deprecated, as it is in pymongo since v3.7.0
* Skip tests that cannot be run if there are no local Mongo server, or no available Js runtime
* Handle bytes sort as BinData sort in python3. (559)
* Time the creation of GridFS file to account for that when checking the time difference
* Handle bson.Regex objects as regular expression
* Fix flaky test (again)
* Run all tests with an old version of pymongo to make sure we stay compatible
* Raises an error if the operand of $in is not an array
* Relax the restriction on WriteConcern so that it works with pymongo 3.6.1
* Generate an error on unknown operator as MongoDB server does. For 553
* Fix flaky test in gridfs
* Fix aggregate's $project for the \_id field when it uses an expression
* Fix Travis Python version
* Handle array subfields in the stage of the aggregate pipeline. (549)
* Ensure valid collection names when using the \[...\] accessor on a DB
* Consider "name" argument to create\_index for index name (550)
* Add support for $slice (aggregate). (547)
* Handle aggregate $first and $last operator when data is missing
* Fix demo code in documentation
* Fix propagation of codec\_options from client to database to collection, and set its tz\_aware flag
* Fix behaviour of $all when applied to an array
```
### 3.17.0
```
* Fix the version of MongoDB server installed for test
* Raises a ValueError on sort with an empty list
* Supporting $replaceRoot operation (524)
* Mark the $where operator as not implemented yet
* Find dict even in nested lists
* Allow positional args for with\_options
* Refactor filtering to be able to keep context while filtering: this is not absolutely required at this stage but will help implement the $expr operator
* Mark $text as a missing feature, including the sorting by $text\_score
* When releasing ot Pypi, distribute the sdist as well
* Mark the $expr operator as not implemented yet
* Handle the ordered parameter of insert\_many
* Fix sorting by a dict field
* Fix the $pull operator when using a simple query operator
* Allow the aggregate expression parser to silently ignore missing keys
* Add $graphlookup (523)
* Fix the aggregate function when there is no input
* Added string operations support (517)
* Fix behavior of $eq and $ne for array fields
* BulkOperationBuilder: Call insert\_one rather than deprecated insert (522)
* Fix KeyError in aggregation. Fixes 514
* Fix CI after lib changes
* Accept $regex operator after $not, as it is now OK for MongoDB v4.0.7+
* Fix mongomock.patch using tuples to specify host and port
```
### 3.16.0
```
* Implement the $setUnion operator in the aggregate pipeline. (510)
* Implement the list\_database\_names method introduced in pymongo v3.6
* Fixes use of '\_id': 0, in the $project stage of the aggregate pipeline
* Fix renaming of collections as I discovered mongomock's implementation differed from pymongo's
* Fix logical operator when used with other search filters (506)
* Fix pylint error
* Support max\_time\_ms in find() (501)
```
### 3.15.0
```
* Improve parsing of mongodb URLs
* Fix the use of \`$ne\` with None
* Fix DuplicateKeyError when parse None to sparse unique index (497)
* Implement the $sort and $position modifiers for the $push update operator
* Fix the matched\_count result for bulk writes
* Raise an OperationFailure on unknown top level operator in filter
* Mark $sort and $position modifiers of the $push operator as not implemented yet
* Add the max\_time\_ms method to Cursor
* Fix sorting of cursors as it should be done before projecting
* Support read preference arguments (has no effect, but check types)
* Add a hint method to the Cursor class
* Implement the {'$type': 'timestamp'} option of the $currentDate update operator
* Fix group operations ($min, $max, $avg, $sum) when handling non numeric types, especially None
* Implement the options of the $regex operator
* Add test coverage for the database module
* Check name correctness before creating a collection
* Make distinct() works with list of nested fields
* Allow falsy value for \_id in update operations. (483)
* Raise a WriteError when trying to modify the \_id field
* Implement $count in aggregate pipeline (479)
* Mark options as not implemented yet
* Implement unordered bulk operations
* Implement the $filter operator within the aggregation pipeline
* Handle subfields in the $project stage of the aggregate pipeline
* Fix the $sample stage of the aggregate pipeline when size is lower than the input's collection size
* Implement with\_options when changing write\_concern
* Move handling of persistant data in a store that can be accessed by several MongoClient
* Allow generation of array on the fly in the $project aggregate stage
* Simplify indexes internal management
* Fix operations that reuse fields existing in the original collection
* Fix error when calling with\_options with the wrong type
* Fix getting a missing key for a $group aggregate operation
* Implement the ping command for database
* Implement the operator $in in the aggregate pipeline
* Mark Database's command method as not implemented
* Mark the $in operator in aggregate pipeline to be valid but not implemented yet
```
Links
- PyPI: https://pypi.org/project/mongomock
- Changelog: https://pyup.io/changelogs/mongomock/
This PR updates mongomock from 3.14.0 to 4.1.1.
Changelog
### 4.1.0 ``` Full support (CI) of Python 3.10 and MongoDB v5. * Add support for partialFilterExpression to create\_index (784) * Handle $ in update operations when it is the last field. (787) * Drop system collections on drop\_database calls. (788) * Add support for "number" alias in $type (757) * Allow system vars expressions to generate arrays (619) * Handle $arrayElementAt applied to $filter * $pushall $addToSet dollar operand support (786) * Fix handling non existent fields and other errors in arithmetic operators and grouping. (502) * Add support for allow\_disk\_use (780) * Use class instead of function in patch (768) * Make reading documents more thread safe. 694 (695) * Patch gridfs without using isinstance. (761) * Fix behavior for $type filter on arrays (756) * Fix behavior for $type filter on numeric types (755) * Make find(projection=...) return copies of the values (753) * Add $not as a logic operator (716) * Implement $map operator (738) * Fix aggregation failing if index does not exists, added test (646) * Sublist candidate handling update (676) * Make distinct() work with arrays of dicts (751) * Add let and array\_filters args for update\_ methods * Create the list\_collections method on Database * Keep a client's server info consistent * Get the server info from an env var * Keep the server\_info value in sync with the CI ``` ### 4.0.0 ``` This release mainly brings support for `pymongo` v4. It is still compatible with `pymongo` v3 and despite the major version, in most cases it should be an easy upgrade. Breaking Changes * Drop support for Python 2 * If no `pymongo` is installed at runtime, uses `pymongo` v4 interface ``` ### 3.23.0 ``` * Add default and options to get_default_database() (693) * Bump the version of hacking, setting our flake8 config * Support read\_concern in database.get\_collection() (708) * Support $toLong operator (705) * Fix for {$size: 1} queries on non-existent fields (711) * Parse \`index\` of $arrayElemAt. Fix 607 (701) * Implement the $let operator. (698) * Implement the $expr operator. (538) * Fix some bad indenting * Fail properly on computing the $size of a missing array. (697) * Fix SyntaxWarning about using "is not" with literals * Add support for mergeObjects operator (689) * fix: use group operators in addFields (690) ``` ### 3.22.1 ``` * Fix type stubs for patch and test it to prevent regressions * Fix missing fields management in the graphLookup stage * Allow dot'ted field in connectFrom of $graphLookup aggregation pipeline (686) ``` ### 3.22.0 ``` * Mark $convert and $toLong operators as not implemented yet * Handle negative limit values for cursor * Add filter kwarg to list\_collection\_names (681) * Align equality and hashable capacity on Pymongo's object * Really run tests for Python 3.9 * Add typing stubs * Add the collation property to Cursor * Add Python 3.9 to the test matrix * Accept collation kwarg in update\_one and update\_many * Performance improvement: create only one instance of \_Filterer (674) * Implement '$concatArrays' aggregation pipeline operator (672) ``` ### 3.21.0 ``` * Return the right document for find\_one\_and\_replace using ReturnDocument.AFTER and upsert * Implement basic codec\_options (670) * Add $trim and $dateFromSTring to the unimplemented operators * Stop using obsolete methods in unit tests as much as possible * Implement boolean operators (663) * Implement TTL Indexes (660) * Fix pylint after v2.6.0 release * Introduce Docker to ease local development (659) * Implement the $regexMatch operator. (658) * Implement the $split operator (661) * Upgrade to MongoDB v4.4 * Create a framework to silence some NotImplementedError. (656) * Raise an error when trying to create the same index with different options * Raise a TypeError when creating an index with a wrong param * Fix $elemMatch querying on values directly * Fix $pull update operation when using $in for a nested field * Accept snapshot or other keyword arguments for find, although raise an OperationFailure if it's not falsy * Mark the start\_session method of MongoClient as not implemented * Fix tz awareness for count\_documents and $match in aggregate * Fix a test that was assuming to be run on UTC clock. (652) ``` ### 3.20.0 ``` * Handling truthy and falsy values the way MongoDB does it (651) * Add support for group by DBRefs (636) * Implement $switch operator (645) * Add hint optional argument to bulk operations (compatibility with pymongo v3.11+) * Mark new $regexMatch operator as not implemented * Drop the test database rather than the test collection (601) * Implement $pop (602) * A little fix in the example (644) * Mark $mergeObjects as valid but not implemented * DOC: Clarify how to use mongomock.patch with pymongo (640) * Add many operators from 3.4 release as NotImplemented * Raise a WriteError when trying to update with an empty $set. (623) * Add context mananger methods to mongomock client (633) * Implement $arrayToObject operator (624) * Add support for read concern (628) * Implements $setEquals operator (596) * Update README.rst (621) * Support $sum decimal type of values (618) * Compare UUID values. (616) * Test and fix sorting between mixed types * Fix travis config * $addField(fix): fix the not exist case in $toInt and $toDecimal (612) * Add $toDecimal operator (610) * Project missing fields in a nested dict fix (605) * Dot support for localField (603) * Fix grammar (600) * Mark TTL Index as not implemented * Allow $all to be specified alongside other operators (597) * Handle the specific case of inserting a Timestamp(0,0) to be replaced by the current time. (593) * Add $dateToString opeartor (590) * Support for $slice operator in projection argument (588) ``` ### 3.19.0 ``` * Add an easy way to compare exception types between mongomock and pymongo * collection.py: Fix return value of Collection.documents\_count() (586) * Type conversion (583) * Add the new kwarg bypass\_document\_validation * Add support for subtracting milliseconds from a date (581) * Implement the $addFields (alias $set) stage of aggregate. (574) * Do not modify inserted documents, except for the \_id * Test mongomock on Python 3.8 as well * Add raw batch BSON operations as not implemented (missing) features * Add new aggregation pipeline stages introduced in 4.2 and mark them as not implemented * Silent some new pyint warnings * Raise a NotImplementedError for valid query operators that have not been implemented in Mongomock yet * Raise an error when an aggregate expression contains more than one field. (557) * Fix $ne on arrays * Fix lint error detected by a new version of pylint ``` ### 3.18.0 ``` * Implement the $facet operator. (563) * Fix index creation when a value used in the indexed fields is not hashable (e.g. dict) * Support bson.regex on $not queries (560) * Mark Cursor.count method as deprecated, as it is in pymongo since v3.7.0 * Skip tests that cannot be run if there are no local Mongo server, or no available Js runtime * Handle bytes sort as BinData sort in python3. (559) * Time the creation of GridFS file to account for that when checking the time difference * Handle bson.Regex objects as regular expression * Fix flaky test (again) * Run all tests with an old version of pymongo to make sure we stay compatible * Raises an error if the operand of $in is not an array * Relax the restriction on WriteConcern so that it works with pymongo 3.6.1 * Generate an error on unknown operator as MongoDB server does. For 553 * Fix flaky test in gridfs * Fix aggregate's $project for the \_id field when it uses an expression * Fix Travis Python version * Handle array subfields in the stage of the aggregate pipeline. (549) * Ensure valid collection names when using the \[...\] accessor on a DB * Consider "name" argument to create\_index for index name (550) * Add support for $slice (aggregate). (547) * Handle aggregate $first and $last operator when data is missing * Fix demo code in documentation * Fix propagation of codec\_options from client to database to collection, and set its tz\_aware flag * Fix behaviour of $all when applied to an array ``` ### 3.17.0 ``` * Fix the version of MongoDB server installed for test * Raises a ValueError on sort with an empty list * Supporting $replaceRoot operation (524) * Mark the $where operator as not implemented yet * Find dict even in nested lists * Allow positional args for with\_options * Refactor filtering to be able to keep context while filtering: this is not absolutely required at this stage but will help implement the $expr operator * Mark $text as a missing feature, including the sorting by $text\_score * When releasing ot Pypi, distribute the sdist as well * Mark the $expr operator as not implemented yet * Handle the ordered parameter of insert\_many * Fix sorting by a dict field * Fix the $pull operator when using a simple query operator * Allow the aggregate expression parser to silently ignore missing keys * Add $graphlookup (523) * Fix the aggregate function when there is no input * Added string operations support (517) * Fix behavior of $eq and $ne for array fields * BulkOperationBuilder: Call insert\_one rather than deprecated insert (522) * Fix KeyError in aggregation. Fixes 514 * Fix CI after lib changes * Accept $regex operator after $not, as it is now OK for MongoDB v4.0.7+ * Fix mongomock.patch using tuples to specify host and port ``` ### 3.16.0 ``` * Implement the $setUnion operator in the aggregate pipeline. (510) * Implement the list\_database\_names method introduced in pymongo v3.6 * Fixes use of '\_id': 0, in the $project stage of the aggregate pipeline * Fix renaming of collections as I discovered mongomock's implementation differed from pymongo's * Fix logical operator when used with other search filters (506) * Fix pylint error * Support max\_time\_ms in find() (501) ``` ### 3.15.0 ``` * Improve parsing of mongodb URLs * Fix the use of \`$ne\` with None * Fix DuplicateKeyError when parse None to sparse unique index (497) * Implement the $sort and $position modifiers for the $push update operator * Fix the matched\_count result for bulk writes * Raise an OperationFailure on unknown top level operator in filter * Mark $sort and $position modifiers of the $push operator as not implemented yet * Add the max\_time\_ms method to Cursor * Fix sorting of cursors as it should be done before projecting * Support read preference arguments (has no effect, but check types) * Add a hint method to the Cursor class * Implement the {'$type': 'timestamp'} option of the $currentDate update operator * Fix group operations ($min, $max, $avg, $sum) when handling non numeric types, especially None * Implement the options of the $regex operator * Add test coverage for the database module * Check name correctness before creating a collection * Make distinct() works with list of nested fields * Allow falsy value for \_id in update operations. (483) * Raise a WriteError when trying to modify the \_id field * Implement $count in aggregate pipeline (479) * Mark options as not implemented yet * Implement unordered bulk operations * Implement the $filter operator within the aggregation pipeline * Handle subfields in the $project stage of the aggregate pipeline * Fix the $sample stage of the aggregate pipeline when size is lower than the input's collection size * Implement with\_options when changing write\_concern * Move handling of persistant data in a store that can be accessed by several MongoClient * Allow generation of array on the fly in the $project aggregate stage * Simplify indexes internal management * Fix operations that reuse fields existing in the original collection * Fix error when calling with\_options with the wrong type * Fix getting a missing key for a $group aggregate operation * Implement the ping command for database * Implement the operator $in in the aggregate pipeline * Mark Database's command method as not implemented * Mark the $in operator in aggregate pipeline to be valid but not implemented yet ```Links
- PyPI: https://pypi.org/project/mongomock - Changelog: https://pyup.io/changelogs/mongomock/