Skip to content

feat: create @pgsql/quotes package for PostgreSQL identifier quoting and keyword classification#284

Merged
pyramation merged 3 commits intomainfrom
devin/1772593921-pgsql-quotes
Mar 4, 2026
Merged

feat: create @pgsql/quotes package for PostgreSQL identifier quoting and keyword classification#284
pyramation merged 3 commits intomainfrom
devin/1772593921-pgsql-quotes

Conversation

@pyramation
Copy link
Collaborator

@pyramation pyramation commented Mar 4, 2026

feat: extract @pgsql/quotes package from deparser

Summary

Extracts QuoteUtils and the PostgreSQL keyword list (kwlist) from pgsql-deparser into a new standalone @pgsql/quotes package. This makes PostgreSQL identifier quoting and keyword classification available without pulling in the entire deparser — useful for migration tools, ORMs, query builders, schema generators, etc.

New package (packages/quotes/):

  • src/kwlist.ts — PG17 keyword list with keywordKindOf() and pre-built Set exports
  • src/quote-utils.tsQuoteUtils class (faithful port of PG's quote_identifier() from ruleutils.c)
  • scripts/keywords.ts — canonical generator to re-sync from PostgreSQL's kwlist.h
  • 57 tests covering all quoting methods and keyword classification
  • Zero runtime dependencies

Deparser changes:

  • Added @pgsql/quotes: workspace:* as a dependency
  • src/deparser.ts and src/index.ts now import QuoteUtils directly from @pgsql/quotes
  • Deleted src/kwlist.ts, src/utils/quote-utils.ts, and scripts/keywords.ts from the deparser — these now live exclusively in @pgsql/quotes
  • Removed the keywords npm script from deparser's package.json

Review & Testing Checklist for Human

  • Verify no downstream packages import deleted deparser files directly: src/kwlist.ts, src/utils/quote-utils.ts, and scripts/keywords.ts were removed from the deparser. The deparser's public API (index.ts) still re-exports QuoteUtils from @pgsql/quotes, but anything that imported those internal files by path will break. Grep the version-specific deparser packages and any other consumers.
  • Confirm initial version 17.0.1 is correct for @pgsql/quotes and aligns with the monorepo's versioning strategy
  • Confirm publishConfig.access: "public" is intended for the @pgsql/quotes scope
  • Lockfile noise: The pnpm-lock.yaml diff is large but mostly pnpm quoting-style reformatting — spot-check that no unintended dependency changes snuck in

Suggested test plan:

  1. pnpm --filter @pgsql/quotes test — 57 tests for the new package
  2. pnpm --filter pgsql-deparser test — the deparser has 29 pre-existing failures on main (snapshot drift), unrelated to this PR; confirm no new failures
  3. pnpm build — full workspace build to verify all packages compile cleanly

Notes

…and keyword classification

- Extract QuoteUtils class and kwlist from pgsql-deparser into standalone @pgsql/quotes package
- Include keyword generator script for syncing with PostgreSQL kwlist.h
- Add comprehensive test suite (57 tests)
- Update deparser to depend on @pgsql/quotes and re-export for backwards compatibility
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

The canonical keywords generator now lives in packages/quotes/scripts/keywords.ts.
The deparser's copy is left unchanged as legacy convenience.
- Deparser now imports QuoteUtils directly from @pgsql/quotes (no re-export wrappers)
- Removed deparser's kwlist.ts, quote-utils.ts shim files
- Removed deparser's scripts/keywords.ts (canonical generator is in quotes package)
- Removed 'keywords' script entry from deparser package.json
@pyramation pyramation merged commit 7ffcc68 into main Mar 4, 2026
18 checks 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.

1 participant