Skip to content

Commit 866b662

Browse files
Update utils.py (#225)
* Update utils.py verify get_meta isn't none before requesting db_table * Add passenv to tox.ini * Fix test_explain in sqlite --------- Co-authored-by: Andrew Chen Wang <[email protected]>
1 parent 52406ec commit 866b662

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

Diff for: cachalot/tests/read.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ def test_table_inheritance(self):
907907
def test_explain(self):
908908
explain_kwargs = {}
909909
if self.is_sqlite:
910-
expected = (r'\d+ 0 0 SCAN TABLE cachalot_test\n'
910+
expected = (r'\d+ 0 0 SCAN cachalot_test\n'
911911
r'\d+ 0 0 USE TEMP B-TREE FOR ORDER BY')
912912
elif self.is_mysql:
913913
if self.django_version < (3, 1):

Diff for: cachalot/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ def _get_tables(db_alias, query, compiler=False):
217217

218218
# Gets all tables already found by the ORM.
219219
tables = set(query.table_map)
220-
tables.add(query.get_meta().db_table)
220+
if query.get_meta():
221+
tables.add(query.get_meta().db_table)
221222

222223
# Gets tables in subquery annotations.
223224
for annotation in query.annotations.values():

Diff for: tox.ini

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ envlist =
77
py{38,39,310}-djangomain-{sqlite3,postgresql,mysql}-{redis,memcached,pylibmc,locmem,filebased},
88

99
[testenv]
10+
passenv = *
1011
basepython =
1112
py37: python3.7
1213
py38: python3.8

0 commit comments

Comments
 (0)