Skip to content

MemoryStore __eq__ does not behave as expected #788

Open

Description

@sivonxay

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

Activity

  1. added and removed on May 22, 2023
  2. munrojm commented on May 22, 2023

    @munrojm
    Member

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

  3. self-assigned this
    on Jul 21, 2023
  4. rkingsbury commented on Jul 21, 2023

    @rkingsbury
    Collaborator

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

  5. rkingsbury commented on Aug 25, 2023

    @rkingsbury
    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?

  6. sivonxay commented on Aug 25, 2023

    @sivonxay
    ContributorAuthor

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

  7. added 2 commits that reference this issue on Aug 7, 2026
    df1668a
    789f965
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions