Repository navigation
feat(grid): filter a column by clipboard value (= clipboard, IN clipb… - #1112
zzx04-cool wants to merge 1 commit into
Conversation
…oard) Closes TabularisDB#1032 - add IN operator to buildCellValueFilterClause, formatting each value with formatSqlValueForColumnComparison - add parseClipboardInList: line split, blank-line/duplicate removal, 1000-value cap with truncation flag - add "= clipboard" and "IN (clipboard)" cell context menu entries, hidden for insertion rows, BLOB and JSON cells - add i18n keys in all locales and unit tests for clause building
ab7b599 to
1f4bf48
Compare
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (15 files)
Reviewed by free · Input: 50.2K · Output: 2K · Cached: 170K |
|
Reproducible test report Environment
Test Commands & Results
Pre-existing Failures
Notes for Reviewer
|
debba
left a comment
There was a problem hiding this comment.
Thanks for building this, filtering by a list pasted from somewhere else is a really practical addition. I like that the clipboard is read when the item is clicked rather than when the menu opens, that blank lines and duplicates are dropped, and that the 1000-value cap comes with a toast instead of silently cutting the list. Reusing formatSqlValueForColumnComparison for each IN item also keeps quoting and the PostgreSQL real cast consistent with the existing = filter. The tests and typecheck pass on the branch (cellValueFilter, DataGrid, i18n: 247 tests).
There's one problem I'd like fixed before merging, because it gives wrong results without any warning.
Non-numeric clipboard lines on a numeric column. A very common way to fill the clipboard is copying a column from a spreadsheet, header included. With the clipboard set to:
user_id
1
2
IN (clipboard) on an int column builds `user_id` IN ('user_id', 1, 2) (I checked it through parseClipboardInList + buildCellValueFilterClause with the mysql driver). Then:
- MySQL casts
'user_id'to0, so the filter also returns every row whereuser_id = 0, with only a1292 Truncated incorrect DOUBLE valuewarning that the user never sees. - PostgreSQL rejects the whole query:
ERROR: invalid input syntax for type integer: "id"(same clause shape run against a local PG table).
The same applies to = clipboard when the clipboard holds non-numeric text.
A fix that keeps the feature friendly: when the column is numeric (isNumericColumnType), drop the lines that aren't numbers and show a short toast with how many were skipped, and if nothing numeric is left, show the existing "no filter applied" message. A test with a header line in the clipboard would lock it in.
One coordination note, not something you need to change now: #1081 (still open, waiting for a rebase) moves the "Filter by this value" entries into a submenu and extends CellValueFilterOperator and CELL_VALUE_FILTER_LABEL_KEYS, so the two PRs conflict. Whichever lands second will need to rebase, and ideally these two clipboard entries would live in that submenu too.
Since this is your first PR here: if you feel like it, come say hi on our Discord, we'd be happy to have you around: https://discord.com/invite/K2hmhfHRSt
…oard)
Closes #1032