Skip to content

feat(fuzzy-finder): add role completion for USE <db> ROLE statement#516

Merged
apstndb merged 1 commit intomainfrom
issue-513-role-fuzzy-completion
Feb 24, 2026
Merged

feat(fuzzy-finder): add role completion for USE <db> ROLE statement#516
apstndb merged 1 commit intomainfrom
issue-513-role-fuzzy-completion

Conversation

@apstndb
Copy link
Owner

@apstndb apstndb commented Feb 24, 2026

Summary

Add fuzzy completion support for database roles in the USE statement. When typing USE <db> ROLE and pressing Ctrl+T, the fuzzy finder lists available database roles via the ListDatabaseRoles admin API.

Key Changes

  • client_side_statement_def.go: Added fuzzyCompleteRole enum value and role completion pattern for USE <db> ROLE <partial> (ordered before database pattern for correct specificity)
  • fuzzy_finder.go: Added role completion header, network requirement, fetch dispatch, and fetchRoleCandidates() using ListDatabaseRoles API with sorted results
  • fuzzy_finder_test.go: Added 4 test cases covering trailing space, partial input, case insensitivity, and leading spaces

Test Plan

  • make check passes (test + lint + fmt-check)
  • Manual testing completed — role fuzzy finder works with Ctrl+T
  • Existing fuzzy completion tests pass (no regression)

Fixes #513

Add fuzzy completion support for database roles in the USE statement.
When typing `USE <db> ROLE <Ctrl+T>`, the fuzzy finder lists available
database roles via the ListDatabaseRoles admin API.

Fixes #513

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @apstndb, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the command-line interface by integrating fuzzy completion for database roles within the USE <database> ROLE statement. This feature allows users to quickly find and select available roles, improving efficiency and reducing errors when managing database access.

Highlights

  • Role Completion Enum: Introduced fuzzyCompleteRole enum and its string representation to categorize database role completions.
  • USE <db> ROLE Pattern: Added a new fuzzy completion pattern for USE <db> ROLE <partial> statements, ensuring it is prioritized for accurate suggestions.
  • Role Fetching Logic: Implemented fetchRoleCandidates to retrieve and sort database roles using the ListDatabaseRoles admin API.
  • Network Requirement: Configured fuzzyCompleteRole to require a network call for fetching dynamic role suggestions.
  • Test Coverage: Expanded test suite with four new cases to validate the USE <db> ROLE fuzzy completion under various input conditions.
Changelog
  • internal/mycli/client_side_statement_def.go
    • Added fuzzyCompleteRole to fuzzyCompletionType enum.
    • Extended String() method for fuzzyCompletionType to handle fuzzyCompleteRole.
    • Inserted a new fuzzyArgCompletion entry for USE <db> ROLE <partial> with fuzzyCompleteRole type, positioned before the USE <db> pattern.
  • internal/mycli/fuzzy_finder.go
    • Imported the regexp package.
    • Updated completionHeader to return "Database Roles" for fuzzyCompleteRole.
    • Modified requiresNetwork to include fuzzyCompleteRole as a type requiring network interaction.
    • Added a case to fetchCandidates to call fetchRoleCandidates for fuzzyCompleteRole.
    • Defined extractRoleRe regular expression for parsing role names.
    • Implemented fetchRoleCandidates function to retrieve, extract, and sort database roles from the admin client.
  • internal/mycli/fuzzy_finder_test.go
    • Added test cases for USE mydb ROLE (trailing space), USE mydb ROLE ad (partial input), use db role (lowercase), and USE mydb ROLE (leading spaces) to TestDetectFuzzyContext.
Activity
  • New feature development: Added fuzzy completion for database roles.
  • PR description provides a clear summary, key changes, and test plan.
  • Manual testing and make check verification completed by the author.
  • Addresses and fixes issue Fuzzy completion: Role completion for USE <db> ROLE #513.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

Code Metrics Report

📊 View detailed coverage report (available for 7 days)

main (4beb392) #516 (853d721) +/-
Coverage 68.2% 68.0% -0.2%
Code to Test Ratio 1:1.2 1:1.2 -0.1
Test Execution Time 1m12s 1m4s -8s
Details
  |                     | main (4beb392) | #516 (853d721) |  +/-  |
  |---------------------|----------------|----------------|-------|
- | Coverage            |          68.2% |          68.0% | -0.2% |
  |   Files             |             55 |             55 |     0 |
  |   Lines             |           5912 |           5929 |   +17 |
  |   Covered           |           4036 |           4036 |     0 |
- | Code to Test Ratio  |          1:1.2 |          1:1.2 |  -0.1 |
  |   Code              |          13574 |          13611 |   +37 |
+ |   Test              |          16928 |          16960 |   +32 |
+ | Test Execution Time |          1m12s |           1m4s |   -8s |

Code coverage of files in pull request scope (53.9% → 51.6%)

Files Coverage +/- Status
internal/mycli/client_side_statement_def.go 79.5% -0.4% modified
internal/mycli/fuzzy_finder.go 22.1% -2.0% modified

Reported by octocov

@apstndb apstndb added the enhancement New feature or request label Feb 24, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces fuzzy completion for database roles when using the USE <db> ROLE ... statement. The implementation adds a new fuzzyCompleteRole type, defines the corresponding regex pattern for detection, and implements the fetchRoleCandidates function to retrieve roles via the ListDatabaseRoles admin API. The changes are consistent with the existing fuzzy-finder architecture and include new tests to validate the behavior. No issues were found that contradict existing code review rules.

@apstndb apstndb merged commit e4b5fb0 into main Feb 24, 2026
2 checks passed
@apstndb apstndb deleted the issue-513-role-fuzzy-completion branch February 24, 2026 19:25
@apstndb apstndb added the fuzzy-finder Fuzzy finder (fzf) completion features label Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request fuzzy-finder Fuzzy finder (fzf) completion features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fuzzy completion: Role completion for USE <db> ROLE

1 participant