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

Cache not invalidated for query using Case annotation for ManyToManyField #259

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sdolemelipone
Copy link

Description

This PR contains a failing test which shows a bug when filtering on annotations of a ManyToManyField. The cache isn't invalidated but I'm not sure why. I've added it as PR so hopefully someone more knowledgable of the codebase can diagnose what's going on.

Rationale

This looks like a bug - caches on the tables on which the query filters on should be invalidated. See issue #255.

@coveralls
Copy link

coveralls commented Jul 10, 2024

Pull Request Test Coverage Report for Build 9876302138

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 98.182%

Totals Coverage Status
Change from base Build 9354988105: 0.0%
Covered Lines: 702
Relevant Lines: 715

💛 - Coveralls

@Andrew-Chen-Wang
Copy link
Collaborator

thx!

@sdolemelipone
Copy link
Author

You're welcome! Although it looks like my test isn't failing here...let me look into why that is, it was failing locally...

@sdolemelipone
Copy link
Author

Got it, the test was not being imported in cachalot/tests/__init__.py so tox wasn't running it :-)

@sdolemelipone
Copy link
Author

@Andrew-Chen-Wang would you be able to re-run the workflow, I think this should fail now. Thanks.

@sdolemelipone
Copy link
Author

Thanks, that's failing now. Hopefully someone can figure out why, sorry I can't be more help.

@danlamanna
Copy link
Contributor

FWIW, running test_result_is_incorrectly_cached with the @with_final_sql_check decorator stops the test from failing for me locally. So setting CACHALOT_FINAL_SQL_CHECK to True might solve your problem @sdolemelipone.

@sdolemelipone
Copy link
Author

FWIW, running test_result_is_incorrectly_cached with the @with_final_sql_check decorator stops the test from failing for me locally. So setting CACHALOT_FINAL_SQL_CHECK to True might solve your problem @sdolemelipone.

That's great, thank you! I had no idea that flag existed. Looks like the CACHALOT_FINAL_SQL_CHECK flag is missing from the documentation at https://django-cachalot.readthedocs.io/en/latest/quickstart.html, I expect the docs there need to be rebuilt?

I assumed all tables were captured by cachalot, the comment below from the code was a surprise.

# Tables may be overlooked by the regular checks as not all expressions are handled yet.

It would be useful to have a list of all the known expressions which aren't handled in the documentation.

I'll leave this PR open for now as an example of one of the overlooked tables cases. Thanks again for your help.

@sdolemelipone
Copy link
Author

@danlamanna I see you've already raised everything I asked about in #265 and #266, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants