You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(v18): commit the outputs for every kitchen-sink statement - #221
18.2.5 changed 1,000+ fingerprints and the parse output without anyone noticing, because no test stated what the outputs are. This commits them, so any output change shows up as a failing test and as a diff in the PR that causes it. No comparison with a published version.
versions/18/test/snapshots/corpus.json: the 24,159 kitchen-sink statements, copied from pgsql-parser's __fixtures__/generated/generated.json (at pgsql-parser@1069446).
versions/18/test/snapshots/pg18.json: one line per statement with the fingerprint and a 12-hex sha256 of the parseSync tree (without version), the normalizeSync query and the scanSync tokens. A thrown error is stored as error: <message>.
versions/18/test/snapshots.test.js: runs the corpus (about 2 s) and lists each changed output as name column: old -> new.
When a change is intended: UPDATE_SNAPSHOTS=1 node --test test/snapshots.test.js, and the diff of pg18.json shows how many statements and which functions it touched.
The test fails on builds whose outputs differ
Same file pointed at published packages (Node 22):
Release
Result
18.1.5
fail, 3,169 outputs changed (fingerprint and parse)
18.2.4
fail, 3,169 outputs changed
18.2.7
pass
this build
pass
Things to know
Hashes, not full outputs: full parse trees for this corpus are tens of MB. The test names the statement and function; the old output comes from running the previous build.
Both files are 2.5–2.9 MB and are not published (files is wasm/*).
PL/pgSQL fixtures (parsePlPgSQL) are not included.
The snapshot was generated on Linux; macOS and Windows CI show whether outputs are identical across platforms.
Added automated snapshot checks for PostgreSQL 18 statements, covering fingerprints, parse trees, normalized queries, and scan-token output.
The checks compare results with stored snapshots and report differences, helping identify changes in query-processing outputs. Snapshots can also be regenerated when expected outputs change.
This PR introduces a versioned PostgreSQL 18 test suite for libpg-query-node. It pins the @libpg-query/parser dependency in the version manifest and adds a snapshot test runner that parses a SQL corpus and compares parse output against committed golden files, including regeneration support via an update mode. No code defects above the reporting threshold were found; one low-severity robustness note about the snapshot-regeneration write path (non-atomic fs.writeFileSync with no post-write verification) fell just below the confidence cutoff and is not included inline.
Files
Change
versions/18/package.json
Pins the PostgreSQL 18 parser dependency for the new versioned suite.
versions/18/test/snapshots.test.js
New snapshot harness: parses the corpus and diffs parse output against the golden file, with an update-regeneration mode.
versions/18/test/snapshots/corpus.json
Adds the SQL corpus fixture (~thousands of statements) used as snapshot input.
versions/18/test/snapshots/pg18.json
Adds the committed golden parse-output snapshot for the corpus.
Adds PG18 snapshot tests that compute fingerprint, parse-tree, normalized-query, and scan-token outputs for corpus statements. The test can write updated snapshots or compare outputs with the existing snapshot. The package test script now runs this test.
Changes: PG18 snapshot testing
Layer / File(s)
Summary
Output helpers versions/18/test/snapshots.test.js
Adds helpers to compute and serialize fingerprint, parse-tree, normalized-query, and scan-token outputs. Errors are recorded as output strings.
Corpus snapshot test and test script versions/18/test/snapshots.test.js, versions/18/package.json
Loads the WASM module and processes each corpus statement. With UPDATE_SNAPSHOTS set, the test writes pg18.json; otherwise, it checks statement names and outputs. The package test script includes the test.
constructive-io/libpg-query-node#204: Changes error handling for PG18 functions whose outputs this test records, which may change snapshot entries.
Suggested reviewers:luxor-code-review
Security architecture risk: Minimal · up to 44b85
The new test checks parser outputs against a committed baseline. It does not change the published package interface or production behavior.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "test(v18): commit the outputs for every kitchen-sink statement" matches the main change. The PR adds committed snapshot outputs (fingerprint, parse-tree hash, normalized query, scan tokens)…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "test(v18): commit the outputs for every kitchen-sink statement" matches the main change. The PR adds committed snapshot outputs (fingerprint, parse-tree hash, normalized query, scan tokens) for every kitchen-sink SQL statement in the v18 test suite, and adds a snapshot test that compares these outputs. The title is specific, concise, and follows the conventional commit style. It does not describe the package.json test-script change in detail, which is expected for a title.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Review coverage is incomplete: 2 files could not be fully reviewed. Findings from completed review steps are included; see review info for details.
This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.
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
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
18.2.5 changed 1,000+ fingerprints and the parse output without anyone noticing, because no test stated what the outputs are. This commits them, so any output change shows up as a failing test and as a diff in the PR that causes it. No comparison with a published version.
versions/18/test/snapshots/corpus.json: the 24,159 kitchen-sink statements, copied from pgsql-parser's__fixtures__/generated/generated.json(atpgsql-parser@1069446).versions/18/test/snapshots/pg18.json: one line per statement with the fingerprint and a 12-hex sha256 of theparseSynctree (withoutversion), thenormalizeSyncquery and thescanSynctokens. A thrown error is stored aserror: <message>.versions/18/test/snapshots.test.js: runs the corpus (about 2 s) and lists each changed output asname column: old -> new.When a change is intended:
UPDATE_SNAPSHOTS=1 node --test test/snapshots.test.js, and the diff ofpg18.jsonshows how many statements and which functions it touched.The test fails on builds whose outputs differ
Same file pointed at published packages (Node 22):
Things to know
filesiswasm/*).parsePlPgSQL) are not included.Implemented in session Find why regressions slip past our release process
Review with Devin · Open in Devin Desktop
Summary by CodeRabbit