Skip to content

Conversation

@pyramation
Copy link
Collaborator

@pyramation pyramation commented Dec 22, 2025

Summary

Removes the hardcoded RESERVED_WORDS Set from quote-utils.ts and replaces it with imports from the generated kwlist.ts. This eliminates duplication and ensures quote-utils stays in sync with PostgreSQL's keyword definitions.

Changes:

  • quote-utils.ts: Removed 15-line hardcoded RESERVED_WORDS Set, now imports RESERVED_KEYWORDS and TYPE_FUNC_NAME_KEYWORDS from kwlist.ts
  • kwlist.ts: Added explicit Set<string> type annotations to exported Sets (required for TypeScript compatibility when calling .has() with a string argument)
  • scripts/keywords.ts: Updated the generator script to include Set<string> type annotations, ensuring they persist when kwlist.ts is regenerated
  • deparser.ts: Removed Deparser.RESERVED_WORDS and Deparser.needsQuotes(), replaced with QuoteUtils.quoteString() - all quoting logic is now centralized in QuoteUtils

Review & Testing Checklist for Human

  • Verify keyword coverage: The old RESERVED_WORDS combined both reserved keywords and type/func name keywords. Confirm that RESERVED_KEYWORDS.has(x) || TYPE_FUNC_NAME_KEYWORDS.has(x) covers the same set of words
  • Test identifier quoting: Try deparsing SQL with identifiers that are reserved words (e.g., SELECT "user", "table" FROM foo) to verify quoting behavior is unchanged
  • Check edge cases: Test identifiers that were in the old list but might be categorized differently in kwlist.ts

Recommended test plan: Run the deparser on a variety of SQL statements with reserved word identifiers and compare output before/after this change.

Notes

284 of 285 deparser tests pass. There is one pre-existing test failure (latest-postgres-create_view.test.ts) related to system_user function formatting (COERCE_SQL_SYNTAX vs COERCE_EXPLICIT_CALL) that is unrelated to this change. The pre-existing eslint config issues and proto-parser test failures are also unrelated.

Link to Devin run: https://app.devin.ai/sessions/de94b880ef5243deb4a8e76adb6875d6
Requested by: Dan Lynch (@pyramation)

- Remove hardcoded RESERVED_WORDS from quote-utils.ts
- Import RESERVED_KEYWORDS and TYPE_FUNC_NAME_KEYWORDS from kwlist.ts
- Add explicit Set<string> type annotations to kwlist.ts exports for proper TypeScript compatibility
- QuoteUtils.needsQuotes() now uses the centralized keyword sets

Co-Authored-By: Dan Lynch <[email protected]>
@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

devin-ai-integration bot and others added 2 commits December 22, 2025 02:07
…ions

The generated kwlist.ts needs explicit Set<string> type annotations for
TypeScript compatibility when calling .has() with string arguments.

Co-Authored-By: Dan Lynch <[email protected]>
@pyramation pyramation closed this Dec 22, 2025
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.

2 participants