feat: add plpgsql-parser package for combined SQL + PL/pgSQL parsing#255
Merged
Conversation
- Combined parse function that auto-detects PL/pgSQL functions and hydrates them - Transform API for parse -> modify -> deparse pipeline - Deparse function that handles dehydration and stitching - Re-exports underlying primitives for power users - 7 tests passing
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 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.
feat: add plpgsql-parser package for combined SQL + PL/pgSQL parsing
Summary
Adds a new
plpgsql-parserpackage that provides a unified API for parsing SQL scripts containing PL/pgSQL functions. The package combines the SQL parser and PL/pgSQL parser, automatically detecting and hydrating PL/pgSQL function bodies.Key features:
parse(sql)- Auto-detectsCREATE FUNCTIONstatements withLANGUAGE plpgsqland hydrates themtransform(sql, callback)- Pipeline for parse → modify → deparse workflowsdeparseSync(parsed)- Converts modified AST back to SQL with pretty printingparseSql,parsePlpgsqlBody,deparseSql, etc.) for power usersUpdates since last revision
README.mdwith pretty headers (logo, CI badge, license badge, version badge) to matchplpgsql-deparserstylepgsql-parser,plpgsql-deparser)Review & Testing Checklist for Human
workspace:*forpgsql-deparserandplpgsql-deparser. Confirm the publish pipeline rewrites these to actual version numbers.CREATE FUNCTIONstatements.anytype usage -PlpgsqlFunctionData.hydratedis typed asany(types.ts:15). Consider if stronger typing is needed for downstream consumers.transform()function - OnlytransformSyncis tested; the async variant should be verified manually.extractFunctionInfosilently returnsnullon parse errors (parse.ts:90-92). Confirm this behavior is acceptable vs surfacing errors.Recommended test plan:
npm testinpackages/plpgsql-parser- all 7 tests should passnpm run buildand verify dist output looks correctNotes
@libpg-query/parser,pgsql-deparser,plpgsql-deparser)deparseSyncfunction usesrequire()inside the function body (deparse.ts:85) to avoid import conflicts - this is intentional but worth noting