Repository navigation
fix: parity gaps from 80 production projects (4.0.2) - #15
Merged
Merged
Conversation
Wrong results: an aggregate in a select-list subquery aggregated the outer query; agg(x ORDER BY y) ignored the ORDER BY; json_agg dropped NULLs. Rejected valid SQL: f(unnest(arr)) (lower(unnest(emails)) hit the range overload); RETURNS SETOF <scalar>; outer refs in a subquery FROM call (from jsonb_array_elements(outer.col)); UPDATE/DELETE table aliases; plpgsql FOR-loop record fields in embedded SQL; json -> <non-literal>. Drift: ALTER COLUMN TYPE / RENAME moved the column to the end; INSERT VALUES row-length errors now match postgres' wording. Needs @tinbase/pgsql-ast-parser 12.2.1. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Ran 80 production RapidNative projects (four seeded random sets of 20, the last one unseen while fixing) through rapidnative-website's migration validator on PGlite and on pg-mem, through the real tools:
db_migration_newper migration,db_seed,db_tables/db_describe, lints, generated types, RLS row counts as anon / demo user / stranger, and must-reject / must-accept probes. All 80 now match PGlite (0 differences). Every fix has a minimal repro incorpus-parity.spec.ts.Wrong results (silent)
select id, (select count(*) from c where c.p = p.id) from preturned one row withid: null. Already in 4.0.0.hasAggregno longer descends into subqueries.agg(x ORDER BY y)ignored the ORDER BY (jsonb_agg,string_agg,array_agg, ...). Rows are now fed in order per group; the ORDER BY comparator is shared withorder-by.ts.json_agg/jsonb_aggdropped NULL inputs; postgres keeps them as jsonnull.Valid SQL that was rejected
f(unnest(arr))callsfper element (the result is set-returning):lower(unnest(_emails))resolvedlower(text[])to the range overload.RETURNS SETOF <scalar>SQL functions.(select … from jsonb_array_elements(outer.col))(built against the empty selection so the ref resolves as correlated;FunctionCallTableevaluates non-constant args per outer row).UPDATE t alias/DELETE FROM t alias: the alias names the table, in the statement and its subqueries. RLS still applies.FOR rec IN <query>record in SQL statements inside the loop (update … set x = rec.col), nested loops included; string literals are left alone.json -> key/->>with a column, variable or expression key (needs@tinbase/pgsql-ast-parser12.2.1, json -> / ->> with a non-literal key (12.2.1) sanketsahu/pgsql-ast-parser#2).Drift
ALTER COLUMN … TYPEandRENAME COLUMNkept the column but moved it to the end (generated types listed it last).INSERT … VALUESchecks each row against the target columns first, so a seed row with one value too many reports "INSERT has more expressions than target columns", as postgres does.Checks
bun test: 1345 pass, 0 fail (locally against parser 12.2.1)npm run test:db-toolson this build: 116/116@tinbase/[email protected]is published; then regeneratebun.lockb.Version 4.0.2.
🤖 Generated with Claude Code