Skip to content

feat(BAR-56): Filters the schemas the tree lists with include and exclude regexes - #63

Merged
Bare7a merged 4 commits into
Bare7a:masterfrom
VM-dash:feat/schema-filter
Dec 1, 2026
Merged

Bare7a merged 4 commits into
Bare7a:masterfrom
VM-dash:feat/schema-filter

Conversation

@VM-dash

@VM-dash VM-dash commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

📝 What changed?

Filter schemas… in the schema tree's options menu opens a dialog to hide schemas by name:

  • an on/off switch, an Include regex and an Exclude regex
  • patterns ignore case and match anywhere in the name unless anchored; | means "or" (the placeholder shows ^test.*|-\d$)
  • an empty include keeps every schema, exclude wins, and spaces count (the field says so when a pattern starts or ends with one)
  • while the filter is on, a pattern that doesn't compile shows its error and Save stays disabled; switched off, the filter saves and keeps its patterns

The filter is saved on the connection (schemaFilter in connections.json) and applies to all its databases. Saving updates the tree from what it already loaded, without reloading the schema. The menu item is checked while the filter is on, and the tree says so when the filter hides every schema, even with a search typed. Import data goes into the first schema the tree lists, and turns off when every schema is hidden.

On MySQL / MariaDB and ClickHouse with Show all databases, where databases are schemas, the filter hides databases in the Databases list and the query tab's database menu. The database you pick, and the connection's own, always show.

Closes #66

🧩 Type of change

  • 🐛 Bug fix
  • ✨ Feature
  • ♻️ Refactor
  • ⬆️ Dependencies
  • 📝 Docs or landing page
  • 🛠️ Build, CI or packaging

🧪 Tested

  • By hand on Windows
  • By hand on macOS
  • By hand on Linux
  • Tests workflow on macOS and Windows

📖 Docs

  • Updated the guide
  • Updated the README or landing page
  • No docs needed

📌 Notes

  • SchemaFilter and its matcher live in barsql-core's config, so regex moves there; it was already in the app through other crates. The dialog is schema_filter_dialog.rs, which the sidebar opens on the saved connection.
  • Matching uses the regex crate, which runs in linear time, and a filter compiles once when it changes, not on every redraw.
  • The dialog can't be closed while it saves, shows a failed save inline, and focuses Include when the filter is on.
  • Load errors from schemas the filter hides don't show, and Collapse all ignores hidden schemas.
  • Tests: core tests for matching, error messages, spaces, blank patterns and the saved JSON; tree tests for the empty-state message, a picked database, and a hidden schema's load error and import target; a Databases list test; whole-window scenarios that save the filter without reloading the schema and that a broken pattern saves only when the filter is off. The import scenarios now pick from the bottom of the options menu.
  • Strings in English, German, Bulgarian and Spanish.

…exes

Filter schemas… in the schema tree's options menu opens a dialog with an on/off switch, an include regex and an exclude regex. Patterns ignore case and match anywhere in the name unless anchored, | means or, an empty include keeps every schema and exclude wins. A pattern that doesn't compile shows its error and can't be saved.

The filter is saved on the connection (schemaFilter in connections.json), for all its databases, and saving it refreshes the tree. Switching it off keeps the patterns. When it hides every schema, the tree says so.
@VM-dash
VM-dash marked this pull request as ready for review November 30, 2026 13:19
@Bare7a
Bare7a merged commit dd8df9e into Bare7a:master Dec 1, 2026
3 checks passed
@Bare7a Bare7a changed the title feat: Filters the schemas the tree lists with include and exclude regexes feat(BAR-56): Filters the schemas the tree lists with include and exclude regexes Dec 1, 2026
Bare7a added a commit that referenced this pull request Dec 1, 2026
…lude regexes (#63)

Filter schemas… in the schema tree's options menu hides schemas by name with an include and an exclude regex, saved on the connection for all its databases. Closes #66.
- Dialog: an on/off switch and Include / Exclude fields; patterns ignore case and match anywhere unless anchored, an empty include keeps everything, exclude wins, and spaces count, with a hint when a pattern starts or ends with one; a broken pattern blocks Save only while the filter is on, and switching it off keeps the patterns
- Saving: schemaFilter in connections.json with blank patterns cleared; no reconnect and no schema reload; the dialog can't close mid-save and shows a failed save inline
- Tree: the menu item is checked while the filter is on; the tree says when the filter hides every schema, even during a search; Import data goes to the first listed schema and turns off when every schema is hidden; load errors from hidden schemas don't show; Collapse all ignores hidden schemas
- MySQL / MariaDB and ClickHouse: with Show all databases, the filter hides databases in the Databases list and the query tab's database menu; the picked database and the connection's own always show
- Code: SchemaFilter, SchemaMatcher and database_filter in barsql-core, which now uses regex (already in the exe); the sidebar opens the dialog on the saved connection
- No new crates
- Docs: the schema guide
- Tests: matching, error messages, spaces, blank patterns and the saved JSON; the empty-state message, a picked database, a hidden schema's error and import target; the Databases list; saving without a schema reload; a broken pattern saving only switched off; the import scenarios pick from the bottom of the menu.

---------

Co-authored-by: victormasson <victor.massonv@gmail.com>
Co-authored-by: Bare7a <bare7a@gmail.com>
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.

Filter the schemas the schema tree lists with regexes

3 participants