noripyt / django-cachalot

No effort, no worry, maximum performance.

Home Page:http://django-cachalot.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

fabiocaccamo opened this issue · 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.

Any reproducible project I could take a look at?

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

Any reproducible project I could take a look at?

No, I'm sorry...