Skip to content

Conversation

@rolandwalker
Copy link
Contributor

@rolandwalker rolandwalker commented Jan 19, 2026

Description

Since the pygments library is already required, why not use its list of reserved words for completions?

This fixes #767 and should keep us up-to-date. It's really great to have the JSON_* functions.

Obsoletes #925, and addresses the two points in #925 (comment) .

Compared to the previous code, this PR

  • removes LEN and TOP, which are not MySQL reserved words
  • preserves extra completion candidates containing space, such as ORDER BY

Downsides and bugs:

  • pygments.lexers._mysql_builtins does contain a leading underscore, so we should be aware that the library reserves the right to break this usage. The library version has been more tightly defined to remediate issues here.
  • Similarly, certain tests might become more brittle with regard to library updates.
  • Certain reserved words are duplicated with special commands, so if the first word of a command-line is any of the following, duplicated completions will show, as both upper- and lower-case: exit, help, source, status, system, use. This is fixable, but should we prefer the upper- or lower-case flavor?
  • There are many more completion candidates now, which may inspire us to do further work soon on prioritizing which completions are seen at the top.

Checklist

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

@rolandwalker rolandwalker self-assigned this Jan 19, 2026
Since the pygments library is already required, why not use its list of
reserved words for completions?

This fixes #767 and should keep us up-to-date. It's really great to have
the JSON_* functions.

Obsoletes #925.

Compared to the previous code, this PR

 * removes LEN and TOP, which are not MySQL reserved words
 * preserves extra completion candidates containing space, such as
   "ORDER BY"

Downsides and bugs:

* pygments.lexers._mysql_builtins does contain a leading underscore, so
  we should be aware that the library reserves the right to break this
  usage. The library version has been more tightly defined to remediate
  issues here.
* Similarly, certain tests might become more brittle with regard to
  library updates.
* Certain reserved words are duplicated with special commands, so if
  the first word of a command-line is any of the following, duplicated
  completions will show, as both upper- and lower-case: exit, help,
  source, status, system, use. This is fixable, but should we prefer
  the upper- or lower-case flavor?
* There are _many_ more completion candidates now, which may inspire us
  to do further work soon on prioritizing which completions are seen at
  the top.
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