Apply parameters to sql statement after it has been logged by ActiveRecord #1370
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: