Skip to content

A check of the Modernizer's script path against a real PostgreSQL - #13

Merged
swsarancodes merged 1 commit into
mainfrom
feat/modernizer-batch-script
Oct 25, 2026
Merged

swsarancodes merged 1 commit into
mainfrom
feat/modernizer-batch-script

Conversation

@swsarancodes

Copy link
Copy Markdown
Owner

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 (EXPLAIN in 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 to package.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

  • It needs Docker for the PostgreSQL container (the command is in the script's header).

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.
@swsarancodes
swsarancodes merged commit 61a4fe8 into main Oct 25, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant