feat(traverse): dispatch on bare ParseResult/ScanResult roots + payload guards#314
Merged
Merged
Conversation
…n-object node payloads
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.
Summary
Follow-up robustness pass on #313.
libpg-query'sparseSync()returns the top level as a bare{version, stmts}object — no{ParseResult: {...}}wrapper — sowalk(parseSync(sql), visitor)fell into the generic untagged branch and theParseResult/RawStmtvisitors never fired (visit()was worse: it took the first keyversionas the tag and traversed nothing).When detected, the root is walked as that node via the runtime schema, so
ParseResult→stmts: RawStmt[](untagged elements) → each statement all dispatch correctly:Also hardened
walkNodeto ignore tagged wrappers whose payload isn't an object (e.g.{Weird: 'str'}previously iterated string indices viafor..in).Detection is deliberately root-only — nested
{version, stmts}shapes are untouched (covered by a test). Tagged roots and all other behavior are unchanged. This also benefitsplpgsql-parser'swalkSqlExpressionspath, which passes hydratedparseResultobjects straight towalkSql.Tests
New cases in
packages/traverse/__tests__/typed-fields.test.tsfor bothwalkandvisit: bare parse-result root dispatch, non-root{version, stmts}not misdetected, non-object tagged payload ignored. Full workspace build + tests pass (traverse 29, transform 1437, deparser 714, plpgsql-parser 303, etc.).Link to Devin session: https://app.devin.ai/sessions/0ce0d0a13c624fb8b8eb22c77d448fb6
Requested by: @pyramation