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

Modifying documents returned by search modifies the query cache #516

Open
msiemens opened this issue Feb 25, 2023 Discussed in #515 · 1 comment
Open

Modifying documents returned by search modifies the query cache #516

msiemens opened this issue Feb 25, 2023 Discussed in #515 · 1 comment
Labels
contributions-welcome Happy to accept pull requests for this issue

Comments

@msiemens
Copy link
Owner

Discussed in #515

Originally posted by sakam0to February 23, 2023
A snippt codes

from tinydb import TinyDB, Query
db =  TinyDB("test.json")
db.insert({"id": 1})

q = Query()
records = db.search(q.id == 1)
records[0]["name"] = "N1"

db.search(q.id==1)
>>[{'id': 1, 'name': 'N1'}]
db.all()
>>[{'id': 1}]

You can see that modifications to the search function result affect the later search results. But it doesn't change the records on the disk. Is it expected or not?

@msiemens msiemens added the contributions-welcome Happy to accept pull requests for this issue label Oct 5, 2024
@ShubhamKaudewar
Copy link

We need to remove the cache read until we find a solution. Reading from db is ok than wrong data read from cache after modified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributions-welcome Happy to accept pull requests for this issue
Projects
None yet
Development

No branches or pull requests

2 participants