-
-
Notifications
You must be signed in to change notification settings - Fork 147
Flask-SQLAlchemy 3 compatibility #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -14,13 +14,10 @@ | |||
#) | |||
#app.config['DEBUG_TB_HOSTS'] = ('127.0.0.1', '::1' ) | |||
app.config['SECRET_KEY'] = 'asd' | |||
|
|||
# TODO: This can be removed once flask_sqlalchemy 3.0 ships | |||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we keep this in as a comment with a callout for folks using SQLAlchemy 2.X?
Something like:
# This is no longer needed for Flask-SQLAlchemy 3.0+, if you're using 2.X you'll want to define this:
# app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, probably the safer approach to leave it in. I re-added it here and in the test app.
Changed to your proposal for both test and example.
@davidism, do you have any last minute feedback before I merge this one in? Based on your PR's bullets I think it hits all of the marks. |
src/flask_debugtoolbar/__init__.py
Outdated
@@ -95,6 +95,10 @@ def init_app(self, app): | |||
"The Flask-DebugToolbar requires the 'SECRET_KEY' config " | |||
"var to be set") | |||
|
|||
if not app.config.get("SQLALCHEMY_RECORD_QUERIES", False): | |||
app.logger.warning( | |||
"'SQLALCHEMY_RECORD_QUERIES' ist not set to True. SQL query logging will not be available.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: ist
should be is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Looks good. You could set |
Thanks. If it defaults to true if debug mode is on, I wonder if we should remove this: if not app.config.get("SQLALCHEMY_RECORD_QUERIES", False):
app.logger.warning(
"'SQLALCHEMY_RECORD_QUERIES' is not set to True. SQL query logging will not be available.") Because in theory DBT would expect debug mode to be enabled to function. |
I added |
Thanks, are you feeling good to merge this @Dosenpfand? I think it's ready. |
Yes @nickjj, looks good to me. |
Thanks a lot for the contribution. |
Addresses #185, adds support for flask_sqlalchemy >= 3.0.0