Skip to content

fix(grid): quote copied SQL INSERT identifiers for the active driver - #1258

Closed
tejasvasingh2004 wants to merge 2 commits into
TabularisDB:mainfrom
tejasvasingh2004:fix/copy-sql-insert-identifier-quotes
Closed

tejasvasingh2004 wants to merge 2 commits into
TabularisDB:mainfrom
tejasvasingh2004:fix/copy-sql-insert-identifier-quotes

Conversation

@tejasvasingh2004

Copy link
Copy Markdown
Contributor

Closes #1027

What changed

  • rowsToSqlInsert in src/utils/clipboard.ts now quotes the table and column names with quoteIdentifier instead of hard-coded MySQL backticks.
  • Copy quoted name in the column header menu (DataGrid.tsx) uses the same quoting via formatObjectNameForCopy.
  • The editor's Copy all rows path (Editor.tsx) now passes activeCapabilities ?? activeDriver, so it still quotes correctly when capabilities aren't loaded.

Before (PostgreSQL): INSERT INTO users (id) VALUES (1); ← syntax error
After (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 as quoteIdentifier everywhere else. Value literals and schema qualification are unchanged.

Tests

Updated tests/utils/clipboard.test.ts with cases for MySQL, PostgreSQL and SQL Server, a capabilities object with a custom identifier_quote, and table/column names containing the quote character.

Ran locally: pnpm lint, pnpm typecheck, pnpm build and pnpm test all pass.

@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 latest commit addresses the earlier maintainer feedback: it keeps backticks as the no-driver fallback via quoteCopiedIdentifier, uses a non-default ~ quote in the plugin test, and adds DataGrid component tests for Copy quoted name (PostgreSQL and no-driver cases). Verification covered quoteIdentifier escaping, the copyDriver resolution in DataGrid.tsx, and the Editor's activeCapabilities ?? activeDriver fallback. I did not run the tests. The existing PR conflict with main (the Editor.tsx useCallback deps list) is noted in the maintainer's earlier review and is not part of this review's findings.

Files Reviewed (5 files)
  • packages/web-ui/src/components/ui/DataGrid.tsx
  • packages/web-ui/src/pages/Editor.tsx
  • packages/web-ui/src/utils/clipboard.ts
  • packages/web-ui/tests/components/ui/DataGrid.test.tsx
  • packages/web-ui/tests/utils/clipboard.test.ts
Previous Review Summary

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

Previous review

This review did not finish. Your provider rejected the request. Check your
provider account and settings, then re-run the review. Kilo does not retry
automatically. Any inline comments below are from an earlier review.


Reviewed by claude-sonnet-5.5 · Input: 254 · Output: 2.1K · Cached: 234.6K

Review guidance: REVIEW.md from base branch main

@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 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, rowToSqlInsert now 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.
@tejasvasingh2004
tejasvasingh2004 force-pushed the fix/copy-sql-insert-identifier-quotes branch from 9a7e74f to 565a999 Compare October 23, 2026 14:48
@tejasvasingh2004

Copy link
Copy Markdown
Contributor Author

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.
No-driver fallback is backticks again, as settled in #1051. The INSERT copy and Copy quoted name now share a small quoteCopiedIdentifier helper, so both behave the same, and the fallback goes through quoteIdentifier(name, 'mysql'), so a backtick inside a name is still escaped ( username ``).
Plugin test uses ~ now, so it fails if the capabilities are ignored.
Added DataGrid tests for Copy quoted name: PostgreSQL ("we""ird") and the no-driver fallback.
Locally: typecheck, lint, format:check and build pass, and the clipboard/DataGrid/identifier tests pass (248/248). The only failures in the full suite are runWebUiTasks.test.mjs, which needs bash on PATH and fails the same way on main on Windows.

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!

@debba

debba commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

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 activeCapabilities ?? activeDriver change in the Editor. The provider sets the driver and the capabilities in the same update, right after loading the driver manifest, so the capabilities are only missing when there's no manifest at all, and the fix doesn't need it. Thanks again for the time you put into it, and I hope to see more PRs from you!

@debba debba closed this Oct 23, 2026
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.

[Bug]: Copy as SQL INSERT and "Copy quoted name" always use MySQL backticks

2 participants