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

UncachableQuery raised when exporting models of table even if listed in CACHALOT_UNCACHABLE_APPS. #221

Open
fabiocaccamo opened this issue Oct 13, 2022 · 3 comments

Comments

@fabiocaccamo
Copy link

What happened?

UncachableQuery exception raised when exporting model accounts.Account, even if the app accounts is listed in CACHALOT_UNCACHABLE_APPS:

Settings

CACHALOT_CACHE = "cachalot"
CACHALOT_ENABLED = True
CACHALOT_ONLY_CACHABLE_APPS = [
    # ...
    "website",
]
CACHALOT_UNCACHABLE_APPS = [
    "accounts",
    # ...
]

Error

UncachableQuery: 
  File "cachalot/monkey_patch.py", line 92, in inner
    table_cache_keys = _get_table_cache_keys(compiler)
  File "cachalot/utils.py", line 276, in _get_table_cache_keys
    for t in _get_tables(db_alias, compiler.query, compiler)]
  File "cachalot/utils.py", line 212, in _get_tables
    raise UncachableQuery

What should've happened instead?

No exception should have been raised by django-cachalot.

Steps to reproduce

Env

Django version: Django==3.2.16
Cachalot version: django-cachalot==2.5.2
Database: MySQL
Cache backend: django.core.cache.backends.memcached.PyMemcacheCache

Context

  • I have a table accounts with ~20k entries, in the admin I try to export it almost all rows as .csv, then I end up with the reported error.
  • The account model has not foreign keys to a app.model listed in CACHALOT_ONLY_CACHABLE_APPS.
  • The export works fine if I select just few rows.
  • The export works fine if I don't use django-cachalot at all.
@Andrew-Chen-Wang

This comment was marked as outdated.

@Andrew-Chen-Wang
Copy link
Collaborator

Turns out #220 is discovering that the tables are still being cached.

@fabiocaccamo
Copy link
Author

Any reproducible project I could take a look at?

No, I'm sorry...

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

No branches or pull requests

2 participants