Skip to content

Commit efe447f

Browse files
authored
Fix SQLAlchemy recording warning for versions >= 3 (#233)
2 parents 9b63ad1 + 9656a2c commit efe447f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: src/flask_debugtoolbar/panels/sqlalchemy.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66
else:
77
try:
88
from flask_sqlalchemy.record_queries import get_recorded_queries
9+
debug_enables_record_queries = False
910
except ImportError:
1011
# For flask_sqlalchemy < 3.0.0
1112
from flask_sqlalchemy import get_debug_queries as get_recorded_queries
1213

14+
# flask_sqlalchemy < 3.0.0 automatically enabled
15+
# SQLALCHEMY_RECORD_QUERIES in debug or test mode
16+
debug_enables_record_queries = True
17+
1318
location_property = 'context'
1419
else:
1520
location_property = 'location'
@@ -62,7 +67,10 @@ def extension_used():
6267

6368

6469
def recording_enabled():
65-
return (current_app.debug or current_app.config.get('SQLALCHEMY_RECORD_QUERIES'))
70+
return (
71+
(debug_enables_record_queries and current_app.debug) or
72+
current_app.config.get('SQLALCHEMY_RECORD_QUERIES')
73+
)
6674

6775

6876
def is_available():

0 commit comments

Comments
 (0)