Skip to content
New issue

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

MemoryStore __eq__ does not behave as expected #788

Open
sivonxay opened this issue May 19, 2023 · 4 comments · May be fixed by #846
Open

MemoryStore __eq__ does not behave as expected #788

sivonxay opened this issue May 19, 2023 · 4 comments · May be fixed by #846
Assignees
Labels

Comments

@sivonxay
Copy link
Contributor

When two memory stores are instantiated with the same collection_name, they are isolated and do not interact with each other. When a document is inserted into one MemoryStore, it is not visible from the other MemoryStore. Therefore, one would expect that these stores are not equivalent and the MemoryStore.__eq__() should return False, but this is not the case. Is this intended behavior?

As an example:

from maggma.stores import MemoryStore

store1 = MemoryStore()
store2 = MemoryStore()

store1.connect()
store2.connect()

store1 == store2  # Returns True

store1.update([{"a": 1, "b": 2}, {"a": 2, "b": 3}], 'a')
store1.query_one() # Returns {"_id": <Object Id>, "a": 1, "b": 2}
store2.query_one()  # Returns nothing
@munrojm munrojm added bug and removed bug labels May 22, 2023
@munrojm
Copy link
Member

munrojm commented May 22, 2023

I see the issue here. This should definitely be fixed. Thanks for bringing it up.

@rkingsbury rkingsbury self-assigned this Jul 21, 2023
@rkingsbury
Copy link
Collaborator

I'm investigating some improvements to MemoryStore and will try to tackle this as part of that effort.

@rkingsbury
Copy link
Collaborator

@sivonxay if I am successful replacing mongomock (see #846 ), then this behavior will change. Two MemoryStore instantiated with the same collection name will actually point to the same collection and will evaluate as equal. If they are instantiated with different collection names, they will evaluate unequal.

Does that behavior make sense to you?

@sivonxay
Copy link
Contributor Author

I think that sounds reasonable. That would be behavior I expect from the comparison

@rkingsbury rkingsbury linked a pull request Aug 25, 2023 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants