Skip to content

Conversation

stjohncj
Copy link

@stjohncj stjohncj commented Apr 5, 2022

Added test as well

@steventen
Copy link
Owner

Hi @stjohncj thanks for submitting a PR!

It looks like you want an option to disable the redaction or sanitization process? In that case, I'd prefer a better name other than retain ids, since it may not always be an ID to be removed. Maybe enable_redaction ?

query.gsub!(/(\sVALUES\s)\(.+\)/i, '\1(xxx)')
query.gsub!(/(\s(LIKE|ILIKE|SIMILAR TO|NOT SIMILAR TO)\s)('[^']+')/i, '\1xxx')
query.gsub!(/(\s(LIMIT|OFFSET)\s)(\d+)/i, '\1xxx')
unless @config&.retain_sql_query_ids
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think It's better to return the query directly instead of wrapping everything in the conditional block.

So something like:

Suggested change
unless @config&.retain_sql_query_ids
return query if @config&.retain_sql_query_ids

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants