Skip to content

Commit

Permalink
Fix SQLAlchemy recording warning for versions >= 3 (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
macnewbold committed Mar 20, 2024
2 parents 9b63ad1 + 9656a2c commit efe447f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/flask_debugtoolbar/panels/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
else:
try:
from flask_sqlalchemy.record_queries import get_recorded_queries
debug_enables_record_queries = False
except ImportError:
# For flask_sqlalchemy < 3.0.0
from flask_sqlalchemy import get_debug_queries as get_recorded_queries

# flask_sqlalchemy < 3.0.0 automatically enabled
# SQLALCHEMY_RECORD_QUERIES in debug or test mode
debug_enables_record_queries = True

location_property = 'context'
else:
location_property = 'location'
Expand Down Expand Up @@ -62,7 +67,10 @@ def extension_used():


def recording_enabled():
return (current_app.debug or current_app.config.get('SQLALCHEMY_RECORD_QUERIES'))
return (
(debug_enables_record_queries and current_app.debug) or
current_app.config.get('SQLALCHEMY_RECORD_QUERIES')
)


def is_available():
Expand Down

0 comments on commit efe447f

Please sign in to comment.