Repository navigation
fix(grid): quote copied SQL INSERT identifiers for the active driver - #1258
tejasvasingh2004 wants to merge 2 commits into
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge The latest commit addresses the earlier maintainer feedback: it keeps backticks as the no-driver fallback via Files Reviewed (5 files)
Previous Review SummaryCurrent summary above is authoritative. Previous snapshots are kept for context only. Previous reviewThis review did not finish. Your provider rejected the request. Check your Reviewed by claude-sonnet-5.5 · Input: 254 · Output: 2.1K · Cached: 234.6K Review guidance: REVIEW.md from base branch |
debba
left a comment
There was a problem hiding this comment.
Thanks a lot for this! Using quoteIdentifier and the existing formatObjectNameForCopy, instead of building the quotes by hand, is the right call. The activeCapabilities ?? activeDriver in the Editor's Copy all rows is a good catch too: capabilities are null until the connection data loads, so without it a Postgres copy right after opening a tab would fall through to the no-driver path.
It conflicts with main right now. #676 moved the frontend to packages/web-ui/src. Git handles the move; the only real conflict is the useCallback deps list in Editor.tsx, where main added client, so keep both (client, activeConnectionId, activeCapabilities, activeDriver). I tried that locally: the clipboard, DataGrid and objectNameCopy tests pass and tsc is clean.
A few smaller things:
- With no driver,
rowToSqlInsertnow falls back to double quotes, and the existing test was changed to expect that. In the review of #1051 we settled on keeping backticks as the no-driver fallback, so I'd rather keep that here too. - The "plugin's declared identifier_quote" test uses
", which is also the default, so it passes even if the capabilities are ignored. A non-default character like~would make it meaningful. - There's no component test for the Copy quoted name change in
DataGrid.
Also a heads up: #1051 works on the same issue (#1027), so I'll coordinate between the two before merging anything.
Since this is your first PR here, welcome! If you'd like to hang out with us, we'd be happy to see you on Discord: https://discord.com/invite/K2hmhfHRSt
Copy as SQL INSERT and the column header's Copy quoted name hard-coded MySQL backticks, producing invalid SQL on PostgreSQL, SQLite and SQL Server. Both now quote through quoteIdentifier, so plugin drivers get their declared identifier_quote. The editor's Copy all rows path falls back to the driver id when capabilities are not loaded. Closes TabularisDB#1027
Address review on TabularisDB#1258: the SQL INSERT copy and Copy quoted name share quoteCopiedIdentifier, which falls back to MySQL backticks (with escaping) when no driver is given, as agreed in TabularisDB#1051. The plugin quote test now uses a non-default character, and DataGrid tests cover Copy quoted name for PostgreSQL and for the no-driver fallback.
9a7e74f to
565a999
Compare
|
Thanks for the detailed review and for testing the conflict resolution! Updated: Rebased onto main (packages/web-ui/src). The Editor.tsx deps keep both: client, activeConnectionId, activeCapabilities, activeDriver. And no problem about #1051, it was opened first. If you'd rather merge that one for the clipboard part, I'm happy to close this and send just the Editor.tsx activeCapabilities ?? activeDriver change as a small separate PR, since #1051 doesn't touch the Copy all rows path. Thanks for the Discord invite too, I'll join! |
|
Thanks a lot for this, and sorry for the overlap. #1051 was already working on the same issue (#1027) and has now been merged with the same approach, so I'm closing this one as superseded. I also looked at the |
Closes #1027
What changed
rowsToSqlInsertinsrc/utils/clipboard.tsnow quotes the table and column names withquoteIdentifierinstead of hard-coded MySQL backticks.DataGrid.tsx) uses the same quoting viaformatObjectNameForCopy.Editor.tsx) now passesactiveCapabilities ?? activeDriver, so it still quotes correctly when capabilities aren't loaded.Before (PostgreSQL): INSERT INTO
users(id) VALUES (1); ← syntax errorAfter (PostgreSQL): INSERT INTO "users" ("id") VALUES (1);
Plugin drivers
Plugin drivers get their declared
identifier_quote. If a plugin doesn't declare one, names fall back to double quotes, the same asquoteIdentifiereverywhere else. Value literals and schema qualification are unchanged.Tests
Updated
tests/utils/clipboard.test.tswith cases for MySQL, PostgreSQL and SQL Server, a capabilities object with a customidentifier_quote, and table/column names containing the quote character.Ran locally:
pnpm lint,pnpm typecheck,pnpm buildandpnpm testall pass.