You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, when I run this command. I got this exception on mongomock/collections.py
TypeError: update must be an instance of dict, bson.son.SON, or other type that inherits from collections.Mapping
venv/lib/python3.11/site-packages/mongomock/collection.py:79: TypeError
How can I do this update correctly, using mongomock and updating the someField field correctly?
When the field does not exist someField, it creates a field as an array with value 'foo'.
When the field is an array. Append the foo value.
When the field is someField:null, change/replace the field as array with value someField:['foo']
And how can I fixes this "bug" to accept my update criteria [{'$set': {'someField': {'$ifNull': [{'$concatArrays': ['$someField', ['foo']]}, ['foo']]}}}]. As you can see I use a list [{$set}...]
The text was updated successfully, but these errors were encountered:
lucassimon
changed the title
validate_is_mapping UpdateOne
validate_is_mapping when UpdateOne criteria is a list
Nov 27, 2023
Hello, I am trying to update a document but I got this error. Follow above the command.
So, when I run this command. I got this exception on
mongomock/collections.py
This function validates the option for
update
So, i don't know if it is a bug, because when I ran this command in a mongosh its successfully.
How can I do this update correctly, using mongomock and updating the someField field correctly?
someField
, it creates a field as an array with value 'foo'.foo
value.someField:null
, change/replace the field as array with valuesomeField:['foo']
And how can I fixes this "bug" to accept my update criteria
[{'$set': {'someField': {'$ifNull': [{'$concatArrays': ['$someField', ['foo']]}, ['foo']]}}}]
. As you can see I use a list[{$set}...]
The text was updated successfully, but these errors were encountered: