Closed
Conversation
- Fix ALTER EXTENSION UPDATE TO deparsing: change defname check from 'to' to 'new_version' and output 'UPDATE TO' instead of just 'TO' - Fix ALTER EXTENSION SET SCHEMA deparsing: output 'SET SCHEMA' instead of just 'SCHEMA' - Add AlterExtensionContentsStmt handler for ALTER EXTENSION ADD/DROP statements - All tests pass (285 test suites, 655 tests) 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:
|
This was referenced Jan 6, 2026
devin-ai-integration bot
pushed a commit
that referenced
this pull request
Jan 6, 2026
… PR #229 Add 14 new PL/pgSQL fixtures that exercise the deparser fixes: - PERFORM statement (parser stores as SELECT, deparser strips SELECT) - INTO clause with record field target (recfield qualification) - INTO clause with subquery (depth-aware scanner) - SETOF function with RETURN QUERY and bare RETURN - SETOF function with RETURN NEXT - Void function with bare RETURN - Scalar function with RETURN NULL - OUT parameter function with bare RETURN - RETURNS TABLE function with RETURN QUERY - Trigger functions with complex logic - Procedure (implicit void return) These fixtures are inspired by real-world functions from constructive-db that required the deparser fixes in PR #266. Regenerated generated.json: 190 valid statements (up from 176)
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.
Fix ALTER EXTENSION deparsing and add DRY refactoring for ObjectType
Summary
This PR fixes multiple issues with
ALTER EXTENSIONstatement deparsing and introduces a DRY refactoring for ObjectType keyword mapping:Fixed
ALTER EXTENSION UPDATE TOdeparsing: The deparser was checking fordefname === 'to'but the AST usesdefname === 'new_version', causing it to outputNEW_VERSION 2.0instead ofUPDATE TO '2.0'. Also added proper string quoting since DefElem context returns unquoted values.Fixed
ALTER EXTENSION SET SCHEMAdeparsing: Changed output fromSCHEMAtoSET SCHEMAto match PostgreSQL syntax.Implemented
AlterExtensionContentsStmthandler: Added support forALTER EXTENSION ... ADD/DROP FUNCTION/...statements which were previously unsupported.DRY refactoring: Created centralized
getObjectTypeKeyword()method to eliminate duplicate switch statements inAlterOwnerStmtandAlterObjectSchemaStmt. This reduces ~200 lines of duplicated code.Test results: All 285 test suites pass (655 tests total), including the new
misc-missing-types.test.tsthat was previously failing.Review & Testing Checklist for Human
ALTER EXTENSION UPDATE TO '2.0'produces correctly quoted output - The string quoting logic in DefElem is manually added because DefElem context returns unquoted strings. Test that version strings are properly quoted in the output.getObjectTypeKeyword()is now used by multiple statement types. While CI passes, manually verify a fewALTER ... OWNER TOstatements with different object types still work correctly.ALTER EXTENSION ADD/DROPwith different object types - The newAlterExtensionContentsStmthandler assumes action values of 1 (ADD) and -1 (DROP). Verify this works for both ADD and DROP operations with various object types (FUNCTION, TYPE, etc.).Notes
AlterExtensionContentsStmtare hardcoded based on the AST structure. If these values are incorrect, the handler will produce wrong output.getObjectTypeKeyword()method includes a comprehensive mapping of all ObjectType enum values, but some may not be tested by the current fixture set.Link to Devin run: https://app.devin.ai/sessions/505114984e764debaca3c75b2dab458c
Requested by: Dan Lynch (pyramation@gmail.com) / @pyramation