Skip to content

Commit

Permalink
Update utils.py (#225)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
hho6643 and Andrew-Chen-Wang authored Mar 12, 2023
1 parent 52406ec commit 866b662
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cachalot/tests/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion cachalot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 866b662

Please sign in to comment.