Add log_note execution option - #13435
Open
Yijian6 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a typed Core
log_noteexecution option forEngine,Connection, SQL statements, and per-execution options. The note appears in brackets immediately after the cache statistics badge in the statement parameter log record.Why
Issue #7732 requests a way to tag individual SQL executions in logs without changing the SQL string or compiled cache key. This PR implements the Core portion; automatic notes for ORM eager, lazy, and deferred loaders remain a separate follow-up.
How
DefaultExecutionContextformats the effective note once, and both ordinary execution andinsertmanyvalueslogging paths append it after cache statistics. The option is included in synchronous, asynchronous, statement, legacyQuery, and known execution-option typing surfaces. Existing log output remains unchanged when the option is absent or empty, including hidden-parameter output.Core logging documentation and a SQLAlchemy 2.1 changelog entry are included.
Testing
python -m pytest -n 0 test/engine/test_logging.py test/typing/test_overloads.py -q— 86 passedpython -m mypyon the six changed source modulestools/format_docs_code.py --check-WCoverage includes per-execution, statement, connection, and engine scopes; empty notes; hidden parameters; and multi-batch
insertmanyvalueslogging.Breaking changes
None.
Checklist
This pull request is: