Fixed query logging so that filter parameters are respected#1370
Merged
aidanharan merged 4 commits intorails-sqlserver:8-0-stablefrom Nov 6, 2025
Conversation
…eRecord Prevents sensitive values from by-passing ActiveRecord filtered attributes.
Remove unnecessary duplication Remove some lines added during debugging
Contributor
|
@mtaylor-vailsys Thanks for the PR. It'll be a week or 2 before I have a chance to look at it properly. |
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.
This is related to #1348.
ActiveRecord::ConnectionAdapters::SQLServer::DatabaseStatements#raw_executepreviously transformed the query into a parameterized query, then called the method implementation fromActiveRecord::ConnectionAdapters::AbstractAdapter.The AbstractAdapter impelementation logged the sql statement, then called the
perform_querymethod.Because the parameterized values were included in the sql statement before it was logged, ActiveRecord filter attributes were being bypassed, leaking values into logs that should otherwise have been filtered out.
This PR moves the application of parameters into the sql statement from the
raw_executemethod into theperform_querymethod (after the statement has been logged).This allows SQL statements logged from activerecord-sqlserver-adapter to respect the ActiveRecord filter attributes.
This comes at the cost of no longer logging the exact sql that will be sent to the database server.
Previously, the adapter would have logged a statement like:
The new logs would appear as: