Skip to content

fix(editor): normalize smart quotes in table filter and sort clauses#439

Open
Davydhh wants to merge 2 commits into
TabularisDB:mainfrom
Davydhh:fix/editor-filter-smart-quotes
Open

fix(editor): normalize smart quotes in table filter and sort clauses#439
Davydhh wants to merge 2 commits into
TabularisDB:mainfrom
Davydhh:fix/editor-filter-smart-quotes

Conversation

@Davydhh

@Davydhh Davydhh commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Problem

Loading the row count for a table whose filter contains a quoted string value
failed with ERROR: unterminated quoted string, so the count stayed stuck on
the # button. Filters with only numeric comparisons worked fine.

Root cause

macOS "Smart Quotes" rewrites a typed ' into a curly / (U+2018/U+2019)
in the toolbar's WHERE/ORDER BY inputs. SQL only treats a straight ' as a
string delimiter, so a clause like col = 'value' reached the database as
col = ‘value’: the curly char is an ordinary character and the leftover
straight quote opened a string that never closed. The count query —
SELECT COUNT(*) FROM (…) as count_wrapper — then failed to parse. The grid
query ran before macOS finalized the conversion, which is why only the count
broke.

Fix

Fold typographic quotes back to straight ASCII inside reconstructTableQuery
the single builder every table query (grid and count) flows through — so the
SQL that reaches the database is always valid, regardless of what's stored. This
also fixes it for a filter that was already stored with a curly quote, without
needing to re-apply it.

Testing

  • Added a reconstructTableQuery test: a curly-quote filter reconstructs to
    straight quotes.
  • tsc --noEmit clean; editor util tests pass.

@kilo-code-bot

kilo-code-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • src/utils/editor.ts - Added normalizeSmartQuotes helper and applied it to filterClause and sortClause in reconstructTableQuery
  • tests/utils/editor.test.ts - Added test verifying smart quotes are folded back to straight ASCII in reconstructed queries

Reviewed by kimi-k2.6 · Input: 56.5K · Output: 5.5K · Cached: 36.7K

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