Skip to content

feat(filters): choose case sensitivity for PostgreSQL text filters - #1252

Merged
debba merged 3 commits into
TabularisDB:mainfrom
harshbhx:fix/1164-pg-match-case
Oct 23, 2026
Merged

debba merged 3 commits into
TabularisDB:mainfrom
harshbhx:fix/1164-pg-match-case

Conversation

@harshbhx

Copy link
Copy Markdown
Contributor

Summary

Literal text filters (contains / starts with / ends with) always generated LIKE, so a case-insensitive match was not possible from the structured filter UI. On PostgreSQL-dialect connections the filter row now has a "Match case" toggle: ticked (the default) keeps LIKE, unticked generates ILIKE.

Changes

  • src/utils/filterBar.ts: StructuredFilter gets an optional matchCase (undefined or true = LIKE, false = ILIKE). buildLiteralLikeClause takes an optional {matchCase}; the %, _, quote and escape-character handling is shared, so escaping is identical in both modes. New supportsMatchCaseToggle(driver), which reuses isPostgresDialect.
  • src/components/ui/FilterRow.tsx: a "Match case" checkbox next to the value field, shown only when supportsMatchCase is set and the operator is contains / starts with / ends with. It is a native checkbox inside a <label>, so it is keyboard accessible and has a visible focus ring.
  • src/components/ui/TableToolbar.tsx: passes supportsMatchCaseToggle(quotingDriver) to each row.
  • src/i18n/locales/*.json: toolbar.matchCase and toolbar.matchCaseHint in all 11 locales.

Plugin drivers

The decision is capability-based, not driver-id based: the toggle shows (and ILIKE is generated) for the built-in PostgreSQL driver and for any plugin whose sql_dialect is postgres, including an omitted sql_dialect, which defaults to postgres like isPostgresDialect elsewhere. MySQL, SQLite, MSSQL and other dialects get no toggle, and ILIKE is never generated for them even if a matchCase: false flag is somehow present, so their filters are unchanged. The raw LIKE / NOT LIKE operators are untouched. buildLiteralLikeClause has a second caller, "filter by cell value", which does not pass the option and keeps LIKE.

Tests

  • tests/utils/filterBar.test.ts: default and match-case-on keep LIKE; match-case-off gives ILIKE for all three operators on built-in PostgreSQL and on a plugin declaring sql_dialect: "postgres"; escaping of %, _, ' and ! is the same in both modes; MySQL/SQLite/MSSQL and plugins declaring them never get ILIKE; raw LIKE is untouched; per-filter behaviour through buildStructuredFilterClause; supportsMatchCaseToggle.
  • tests/components/ui/FilterRow.test.tsx: the toggle is hidden without support and for other operators, shown and checked by default, stores matchCase: false when unticked, and reflects an unticked filter.
  • The ILIKE assertions cannot pass without the change. I did not run the suite against the old code.
  • Typecheck, lint, build, vitest and the Postgres/MySQL integration jobs pass on my fork's CI: https://github.com/harshbhx/tabularis/actions/runs/39726848565
  • Not checked by hand in the desktop app against a live PostgreSQL server; ILIKE ... ESCAPE '!' is standard PostgreSQL syntax. The new translations (other than English) are mine and could use a native check.

Closes #1164

Add a Match case toggle to contains / starts with / ends with filters on PostgreSQL-dialect connections. Unticking it generates ILIKE instead of LIKE; the default stays LIKE and other dialects are unchanged.

Closes TabularisDB#1164
<input
type="checkbox"
checked={matchCase}
onChange={(e) => onChange({...filter, matchCase: e.target.checked})}

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.

WARNING: Toggling "Match case" does not reset the filter's applied state

TableToolbar.handleFilterChange (src/components/ui/TableToolbar.tsx, ~line 316) decides whether to call onResetApplied by comparing only column, operator, value and value2. Since matchCase is not part of that comparison, flipping this checkbox is treated as an "only enabled changed" update: the row keeps its "applied" indicator even though the clause it would generate has changed (LIKE <-> ILIKE) and the displayed data no longer matches the filter. Add prev.matchCase === updated.matchCase to the onlyEnabledChanged check, and cover it with a test.

@kilo-code-bot

kilo-code-bot Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

The previously reported issue is resolved: TableToolbar.handleFilterChange now includes the matchCase comparison (treating undefined and true as equivalent) in onlyEnabledChanged, so toggling "Match case" resets the applied state while Apply All selection changes still keep it. A regression test covers both paths.

Files Reviewed (18 files)
  • src/components/ui/FilterRow.tsx
  • src/components/ui/TableToolbar.tsx
  • src/utils/filterBar.ts
  • src/i18n/locales/*.json (11 locales)
  • tests/components/ui/FilterRow.test.tsx
  • tests/components/ui/TableToolbar.test.tsx
  • tests/utils/filterBar.test.ts
Previous Review Summary (commit 0cea48c)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 0cea48c)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
src/components/ui/FilterRow.tsx 180 Toggling "Match case" is not included in TableToolbar.handleFilterChange's onlyEnabledChanged comparison (column/operator/value/value2 only), so the filter's applied state is not reset when LIKE <-> ILIKE changes. Add prev.matchCase === updated.matchCase and a test.
Files Reviewed (16 files)
  • src/components/ui/FilterRow.tsx - 1 issue
  • src/components/ui/TableToolbar.tsx
  • src/utils/filterBar.ts
  • src/i18n/locales/*.json (11 locales)
  • tests/components/ui/FilterRow.test.tsx
  • tests/utils/filterBar.test.ts

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-5.5 · Input: 248 · Output: 1.2K · Cached: 184.1K

Review guidance: REVIEW.md from base branch main

Toggling Match case changes the generated clause, so the row's Applied feedback must be cleared like it is for a column, operator or value change.
@harshbhx

Copy link
Copy Markdown
Contributor Author

Good catch, thanks. Toggling Match case changed the clause but not the row's Applied state. Fixed in c4a2fce: the comparison in handleFilterChange now includes matchCase (an unset value and true count as the same, since both mean LIKE). There is a new test in TableToolbar.test.tsx: after applying a contains filter, deselecting it for Apply All keeps the Applied label, and toggling Match case clears it.

@debba debba left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for picking this up! What I like most is that ILIKE is gated twice, in the UI and again in buildLiteralLikeClause. A stale matchCase: false can never leak ILIKE onto MySQL, SQLite or other dialects, and there's a test for both built-in ids and plugin capability objects. Resetting the row's Applied state when the box is toggled is a good fix too.

I'm requesting changes only because GitHub can't merge it: #676 moved the frontend to packages/web-ui/src. Locally, git follows the renames and the merge goes through cleanly, and the filter, toolbar and i18n tests pass on the merged tree. So a plain rebase on main should do it.

A few nits for while you're there, or later:

  • MATCH_CASE_OPS in FilterRow duplicates LikeMatchMode from filterBar.ts. A small isLikeMatchMode() helper would keep the list in one place.
  • The checkbox uses focus-visible:ring-2 focus-visible:ring-focus/60. .rules/accessibility.md asks for focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus.
  • Some labels are a bit terse for a checkbox. In Italian, "Distingui maiuscole/minuscole" reads more naturally than "Maiuscole/minuscole", and in German "Groß-/Kleinschreibung beachten" works better than the bare noun.

@debba debba left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I merged main into your branch, since the only thing holding it back was the move to packages/web-ui and git handled the renames cleanly, and then tried it in the app. On a Postgres table with Ada / ADA / ada / Adalbert / 100%_off / x_y, contains "ada" with Match case returns only ada. Unticking it flips the row back to Apply, the query switches to ILIKE, and all four Ada rows come back. %_ and _ are still matched literally. Starts with and ends with follow the box too, and it disappears for =, LIKE and IN. On MySQL the box never shows and the filter stays LIKE. Tests are green, so I'm merging it. Thanks again! The nits from my earlier review can go in a follow-up whenever you like.

@debba
debba merged commit 549bbe4 into TabularisDB:main Oct 23, 2026
11 of 12 checks passed
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.

[Feat]: Choose case sensitivity for PostgreSQL text filters

2 participants