We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using the $each modifier with $addToSet doesn't always result in unique values because of how the values of the $each are handled:
$each
$addToSet
https://github.com/mongomock/mongomock/blob/ca41f27161c50d83d5ef8c899623084dd6f09a1d/mongomock/collection.py#LL704C37-L706C80
Example:
import mongomock client = mongomock.MongoClient() coll = client.db.coll id = coll.insert_one({"numbers": []}).inserted_id coll.find_one_and_update({"_id": id}, {"$addToSet": {"numbers": {"$each": [1, 1, 1, 1]}}}) print(coll.find_one({"_id": id}))
This will result in {"numbers": [1, 1, 1, 1]} instead of {"numbers": [1]}.
{"numbers": [1, 1, 1, 1]}
{"numbers": [1]}
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Using the
$each
modifier with$addToSet
doesn't always result in unique values because of how the values of the$each
are handled:https://github.com/mongomock/mongomock/blob/ca41f27161c50d83d5ef8c899623084dd6f09a1d/mongomock/collection.py#LL704C37-L706C80
Example:
This will result in
{"numbers": [1, 1, 1, 1]}
instead of{"numbers": [1]}
.The text was updated successfully, but these errors were encountered: