michaelkryukov / mongomock_motor

Library for mocking AsyncIOMotorClient built on top of mongomock.
MIT License
102 stars 24 forks source link

The fetch_links=True in beanie queries doesn't work #20

Open nemrok opened 1 year ago

nemrok commented 1 year ago

So after getting a document calling fetch_all_links() works however when using the keyword argument it doesn't. Thus you can't do queries comparing the linked document properties. For example the below would not work:

doc = await House.find_one(House.front_door.color == 'Blue', fetch_links=True)

michaelkryukov commented 1 year ago

This looks like same issue with mongomock's implementation of DBRef (which is the core of beanie's links) as discussed in #5. I've created issue at mongomock (mongomock/mongomock#759), but I don't really want to patch internals of mongomock in this library. So currently support for links is limited.

nemrok commented 1 year ago

Thanks so much! In the interim, I changed my code to use fetch_all_links in an async for loop and for cases where I need to use fetch_links I skipped these unit tests for now. I have integration tests to cover these cases. However it would be great to have this working.

mahdian888 commented 1 year ago

Hello, Can you fix this? it shows NotImplementedError: Although 'pipeline' is a valid lookup operator for the aggregation pipeline, it is currently not implemented in Mongomock.

michaelkryukov commented 1 year ago

What exactly is not working for you? This issue refers to the internal implemetation of beanie that doesn't support some operations with DBRef that mongo supports (and beanie uses).