django-cachalot icon indicating copy to clipboard operation
django-cachalot copied to clipboard

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

Open fabiocaccamo opened this issue 2 years ago • 3 comments

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.

fabiocaccamo avatar Oct 13 '22 12:10 fabiocaccamo

Any reproducible project I could take a look at?

Andrew-Chen-Wang avatar Oct 20 '22 17:10 Andrew-Chen-Wang

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

Andrew-Chen-Wang avatar Oct 20 '22 17:10 Andrew-Chen-Wang

Any reproducible project I could take a look at?

No, I'm sorry...

fabiocaccamo avatar Oct 20 '22 19:10 fabiocaccamo