diff --git a/cachalot/tests/read.py b/cachalot/tests/read.py index f45072ffe..a08237e39 100644 --- a/cachalot/tests/read.py +++ b/cachalot/tests/read.py @@ -907,7 +907,7 @@ def test_table_inheritance(self): def test_explain(self): explain_kwargs = {} if self.is_sqlite: - expected = (r'\d+ 0 0 SCAN TABLE cachalot_test\n' + expected = (r'\d+ 0 0 SCAN cachalot_test\n' r'\d+ 0 0 USE TEMP B-TREE FOR ORDER BY') elif self.is_mysql: if self.django_version < (3, 1): diff --git a/cachalot/utils.py b/cachalot/utils.py index a20d2a623..9df2a74ec 100644 --- a/cachalot/utils.py +++ b/cachalot/utils.py @@ -217,7 +217,8 @@ def _get_tables(db_alias, query, compiler=False): # Gets all tables already found by the ORM. tables = set(query.table_map) - tables.add(query.get_meta().db_table) + if query.get_meta(): + tables.add(query.get_meta().db_table) # Gets tables in subquery annotations. for annotation in query.annotations.values(): diff --git a/tox.ini b/tox.ini index 8e200ec5c..166b3597c 100644 --- a/tox.ini +++ b/tox.ini @@ -7,6 +7,7 @@ envlist = py{38,39,310}-djangomain-{sqlite3,postgresql,mysql}-{redis,memcached,pylibmc,locmem,filebased}, [testenv] +passenv = * basepython = py37: python3.7 py38: python3.8