Skip to content

Don't persist password-change SQL statements to the history file#1835

Merged
rolandwalker merged 1 commit intomainfrom
RW/do-not-persist-password-changes-in-history
Apr 13, 2026
Merged

Don't persist password-change SQL statements to the history file#1835
rolandwalker merged 1 commit intomainfrom
RW/do-not-persist-password-changes-in-history

Conversation

@rolandwalker
Copy link
Copy Markdown
Contributor

Description

Leveraging the new is_password_change() detection from #1829, avoid persisting password-change statements to the history file, but leave them available for navigation in the current session.

Wrap the sqlglot.tokenize() call for is_password_change() in a try block, since it could throw if given invalid SQL.

Add and improve tests for sql_utils.py.

Checklist

  • I added this contribution to the changelog.md file.
  • I added my name to the AUTHORS file (or it's already there).
  • To lint and format the code, I ran
    uv run ruff check && uv run ruff format && uv run mypy --install-types .

@rolandwalker rolandwalker self-assigned this Apr 11, 2026
@rolandwalker rolandwalker force-pushed the RW/do-not-persist-password-changes-in-history branch from 139c530 to 42460af Compare April 11, 2026 16:03

history.append_string('SELECT 1')

assert history._loaded_strings[0] == 'SELECT 1'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could this (and the one below) use the public method get_strings() instead of this private method?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. Done!

Copy link
Copy Markdown
Contributor

@scottnemes scottnemes left a comment

Choose a reason for hiding this comment

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

Looks good overall; see the one comment if you want to address it.

Leveraging the new is_password_change() detection, avoid persisting
password-change statements to the history file, but leave them available
for navigation in the current session.

Wrap the sqlglot.tokenize() call for is_password_change() in a try
block, since it could throw if given invalid SQL.

Add and improve tests for sql_utils.py.
@rolandwalker rolandwalker force-pushed the RW/do-not-persist-password-changes-in-history branch from 42460af to 75db244 Compare April 13, 2026 10:24
@rolandwalker rolandwalker merged commit f6b8dec into main Apr 13, 2026
8 checks passed
@rolandwalker rolandwalker deleted the RW/do-not-persist-password-changes-in-history branch April 13, 2026 10:28
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.

2 participants