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
When projecting a computed field from an embedded/nested document, mongomock returns the embedded object instead of the computed result.
project
Example document:
document = { "a": "test_a", "embedded": { "embedded_key": "test_embedded", }, }
querying that with projection={"embedded": "$embedded.embedded_key"} results in:
projection={"embedded": "$embedded.embedded_key"}
mongomock:
{'embedded': {'embedded_key': 'test_embedded'}}
the expected result is:
{'embedded': 'test_embedded'}
This bug is possibly related to/a dupe of #835
Full reproducible example:
import mongomock import pymongo def main(client: mongomock.MongoClient): collection = client["db_test"]["users"] document = { "a": "test_a", "embedded": { "embedded_key": "test_embedded", }, } result = collection.insert_one(document) projection = {"embedded": "$embedded.embedded_key"} db_doc = collection.find_one({"_id": result.inserted_id}, projection=projection) client.close() return db_doc if __name__ == "__main__": MONGODB_URI = "<your url here>" client = pymongo.MongoClient(host=MONGODB_URI) pymongo_res = main(client) client = mongomock.MongoClient() mongomock_res = main(client) print(pymongo_res) print(mongomock_res) assert pymongo_res == mongomock_res
The text was updated successfully, but these errors were encountered:
No branches or pull requests
When
project
ing a computed field from an embedded/nested document, mongomock returns the embedded object instead of the computed result.Example document:
querying that with
projection={"embedded": "$embedded.embedded_key"}
results in:mongomock:
the expected result is:
This bug is possibly related to/a dupe of #835
Full reproducible example:
The text was updated successfully, but these errors were encountered: