Repository navigation
A check of the Modernizer's script path against a real PostgreSQL - #13
Merged
Merged
Conversation
scripts/modernizer-batch.ts writes the golden corpus into one script per source dialect, splits and converts it the way a user's file is, and has PostgreSQL check every statement with EXPLAIN in a read-only transaction. The corpus already knows what each query must do, so the statuses are compared with that: a statement the corpus knows is not converted, or can return different rows, must never end up as plain converted, and one whose rows were proved identical must never end up failed. Exit code 1 on any disagreement. npm run test:batch.
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.
What changed
scripts/modernizer-batch.ts(npm run test:batch, documented in the README's Query Modernizer section) was never in the repository. It writes the Modernizer's golden corpus into one script per source dialect, splits and converts it the way a user's file is, and has PostgreSQL check every statement (EXPLAINin a read-only transaction). The corpus already knows what each query must do, so the check is that the statuses agree: a statement the corpus knows is not converted, or can return different rows, must never end up as plain "converted", and one whose rows were proved identical must never end up "failed". Exit code 1 on any disagreement. One line is added topackage.json.How it was checked
Run for this PR against a real PostgreSQL 16 (
docker run … postgres:16, port 54329): 351 corpus queries in 353 statements, 248 converted, 35 unchanged, 21 needing review, 44 failed (not converted, listed with why) and 3 out of scope, checked by PostgreSQL in 0.2 s, 0 disagreements with the corpus. Five queries that need their own setup tables are left out; three statements the corpus proved correct are marked "needs review" for a stated reason (a case-insensitive text comparison) and are listed, which is not a disagreement.Reviewer notes