pallets-eco / flask-debugtoolbar

A toolbar overlay for debugging Flask applications
https://flask-debugtoolbar.readthedocs.io
BSD 3-Clause "New" or "Revised" License
952 stars 146 forks source link

NameError: 'debug_enables_record_queries' on visiting Flask routes when toolbar enabled #252

Closed joelburton closed 7 months ago

joelburton commented 7 months ago

Previously-to-0.15.0, our Flask app starts successfully and DBT is visible and working.

Under 0.15.0, we now get this:

image

We are not using SQLAlchemy in this app, but it appears that the DBT is checking for "record queries" option that Flask-SQLAlchemy + the toolbar use.

joelburton commented 7 months ago

The error appears to come from the SQLAlcehmy panel code:

try:
    from flask_sqlalchemy import SQLAlchemy
except ImportError:
    sqlalchemy_available = False
    get_recorded_queries = SQLAlchemy = None

    #### MISSING CHANCE TO SET debug_enabled_record_queries = False  HERE      <======

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'
    sqlalchemy_available = True