Skip to content

fix: quote identifiers in object preview queries - #39

Merged
tianzhou merged 1 commit into
pgplex:mainfrom
sphr2k:fix/quote-object-select-identifiers
Oct 28, 2026
Merged

tianzhou merged 1 commit into
pgplex:mainfrom
sphr2k:fix/quote-object-select-identifiers

Conversation

@sphr2k

@sphr2k sphr2k commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Fix table/view previews from the object browser generating unquoted identifiers, which breaks mixed-case names, reserved words, and names containing spaces or punctuation.
  • Add a shared generateObjectSelect helper that quotes schema and object names separately and escapes embedded double quotes.
  • Reuse the helper in table and view “New Query” actions and add five parameterized regression cases using generic fixture names.

Notes

The preview limit remains 100. For example, the object browser now generates SELECT * FROM "ExampleSchema"."ExampleTable_V01" LIMIT 100; instead of folding the mixed-case identifiers to lowercase.

Local validation used pnpm 10, which supports the repository's existing pnpm.overrides configuration. No dependency or lockfile changes were needed.

Validation

  • git diff upstream/main...HEAD --check
  • npm exec --yes --package=pnpm@10 -- pnpm install --frozen-lockfile (passes)
  • npm exec --yes --package=pnpm@10 -- pnpm exec vitest run tests/sql-generate.test.ts (1 file, 15 tests passed)

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

The PR fixes object preview queries by quoting schema and object names separately.

  • Table and view previews keep schema and object names intact.

No actionable issues were found. Tests were not run during this review.

Reviews (2) · Last reviewed commit: "fix: quote identifiers in object preview..." · Reviewed by Greptile

@sphr2k sphr2k closed this Oct 28, 2026
@sphr2k sphr2k reopened this Oct 28, 2026
@sphr2k
sphr2k force-pushed the fix/quote-object-select-identifiers branch from bf67552 to 8ae2902 Compare October 28, 2026 09:55
@tianzhou
tianzhou requested a balanced review from Copilot October 28, 2026 09:57

Copilot AI left a comment

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.

🟢 Approval recommended

No active review issues were identified for the PostgreSQL identifier-quoting changes.

No open issues 🎉

What changed in this PR

Fixes object-browser preview queries for PostgreSQL identifiers containing mixed case, reserved words, spaces, punctuation, or embedded double quotes.

Changes:

  • Adds a shared generateObjectSelect helper that quotes schema and object names separately and escapes embedded quotes.
  • Uses the helper for object previews and table/view “New Query” actions, preserving the 100-row limit.
  • Adds five parameterized regression cases covering identifier quoting.
File Description
tests/​sql-generate.test.ts Adds five identifier-quoting regression cases.
src/​lib/​sql/​generate.ts Introduces the shared preview-query helper.
src/​components/​sql-editor/​SQLEditorLayout.tsx Uses quoted identifiers in object-browser previews.
src/​components/​sql-editor/​schema/​ViewSchemaContent.tsx Uses the helper for view “New Query” actions.
src/​components/​sql-editor/​schema/​TableSchemaContent.tsx Uses the helper for table “New Query” actions.

Review effort: Balanced

@tianzhou tianzhou left a comment

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.

LGTM. Thanks for the contribution.

@tianzhou
tianzhou merged commit 1e3cde4 into pgplex:main Oct 28, 2026
1 check 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.

3 participants