refactor: centralize quote-utils to use generated kwlist.ts#240
Closed
pyramation wants to merge 3 commits intofeat/keywordsfrom
Closed
refactor: centralize quote-utils to use generated kwlist.ts#240pyramation wants to merge 3 commits intofeat/keywordsfrom
pyramation wants to merge 3 commits intofeat/keywordsfrom
Conversation
- 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 <pyramation@gmail.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…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 <pyramation@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes the hardcoded
RESERVED_WORDSSet fromquote-utils.tsand replaces it with imports from the generatedkwlist.ts. This eliminates duplication and ensures quote-utils stays in sync with PostgreSQL's keyword definitions.Changes:
quote-utils.ts: Removed 15-line hardcodedRESERVED_WORDSSet, now importsRESERVED_KEYWORDSandTYPE_FUNC_NAME_KEYWORDSfromkwlist.tskwlist.ts: Added explicitSet<string>type annotations to exported Sets (required for TypeScript compatibility when calling.has()with astringargument)scripts/keywords.ts: Updated the generator script to includeSet<string>type annotations, ensuring they persist when kwlist.ts is regenerateddeparser.ts: RemovedDeparser.RESERVED_WORDSandDeparser.needsQuotes(), replaced withQuoteUtils.quoteString()- all quoting logic is now centralized inQuoteUtilsReview & Testing Checklist for Human
RESERVED_WORDScombined both reserved keywords and type/func name keywords. Confirm thatRESERVED_KEYWORDS.has(x) || TYPE_FUNC_NAME_KEYWORDS.has(x)covers the same set of wordsSELECT "user", "table" FROM foo) to verify quoting behavior is unchangedRecommended 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 tosystem_userfunction formatting (COERCE_SQL_SYNTAXvsCOERCE_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)