Commit c186f40 1 parent 23917b8 commit c186f40 Copy full SHA for c186f40
File tree 1 file changed +14
-11
lines changed
1 file changed +14
-11
lines changed Original file line number Diff line number Diff line change
1
+ import contextlib
1
2
import logging
2
3
import traceback
3
4
4
5
from django .apps import apps
5
- from django .db import connection
6
+ from django .db import NotSupportedError , connection
6
7
from django .utils import timezone
7
8
from django .utils .encoding import force_str
8
9
@@ -83,16 +84,18 @@ def _should_wrap(self, sql_query):
83
84
return False
84
85
85
86
# Must not try to explain 'EXPLAIN' queries or transaction stuff
86
- if any (
87
- sql_query .startswith (keyword )
88
- for keyword in [
89
- 'SAVEPOINT' ,
90
- 'RELEASE SAVEPOINT' ,
91
- 'ROLLBACK TO SAVEPOINT' ,
92
- 'PRAGMA' ,
93
- connection .ops .explain_query_prefix (),
94
- ]
95
- ):
87
+ unexplainable_keywords = [
88
+ 'SAVEPOINT' ,
89
+ 'RELEASE SAVEPOINT' ,
90
+ 'ROLLBACK TO SAVEPOINT' ,
91
+ 'SET SESSION TRANSACTION' ,
92
+ 'SET CONSTRAINTS' ,
93
+ 'PRAGMA' ,
94
+ ]
95
+ with contextlib .suppress (ValueError , NotSupportedError ):
96
+ unexplainable_keywords .append (connection .ops .explain_query_prefix ())
97
+ unexplainable_keywords .append (connection .ops .explain_query_prefix (analyze = True ))
98
+ if any (sql_query .startswith (keyword ) for keyword in unexplainable_keywords ):
96
99
return False
97
100
98
101
for ignore_str in SilkyConfig ().SILKY_IGNORE_QUERIES :
You can’t perform that action at this time.
0 commit comments