Repository navigation
fix: numeric/bigint aggregates, enum order, quoted plpgsql idents, json dates (4.0.4) - #18
Merged
Merged
Conversation
…on dates (4.0.4) Wrong results: sum() concatenated numeric/bigint digit strings and avg used that; max/min compared them as text; enums ordered alphabetically. Rejected valid SQL: new."col" in triggers (quoted identifiers split into three plpgsql tokens). JSON dates/times now use postgres' text format; numerics in json builders are numbers. Validator-facing errors use postgres' wording. 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.
More testing of rapidnative-website's migration validator over the same 120 production projects, PGlite vs pg-mem, now with (a) ~4,500 mutation probes generated from each project's own schema (must-reject: policy on a missing column,
uuid = text/int = text/bool = text, non-boolean policy, retyping a policy column, trigger on a missing function, wrong-type insert, dangling FK, duplicate column, duplicate seed rows, NULL into NOT NULL; must-accept: add column, index, casted policy, comment,updated_attrigger, CHECK) and (b) reads over the seeded data: every row of every table, sum/max/min/count/avg over every numeric column, ordered reads, row_to_json, catalogue reads.Wrong results (all already in 3.5.0)
sum()over numeric / bigint concatenated the digit strings:sumof 10 and 32.5 was'1032.5', bigint 5 + 7 was'57';avgwas computed from that (orNaN). Now exact (Decimal / BigInt), sosum(0.1, 0.2)is0.3and large bigints keep their digits.max/mincompared numeric / bigint as text (maxof 9 and 10 was'9'). Now by type.order by priority,priority > 'medium', andmax/min(which now accept enums).Rejected valid SQL
new."updated_at" := now()in a trigger failed to compile (299 of the probes). Quoted names now work in triggers, functions and DO blocks.JSON output
"2026-05-26","2026-05-26T10:30:00","2026-05-26T10:30:00.5+00:00") instead of JStoISOString(), inrow_to_json,json_agg,to_json[b],json[b]_build_object,json[b]_build_array. tinbase builds REST answers withrow_to_json, so this matters for the editor too. Numerics inside the json builders are numbers, as in Postgres.Postgres wording for errors the validator shows the model
column "x" of relation "t" already exists(42701),null value in column "x" of relation "t" violates not-null constraint(23502),argument of POLICY must be type boolean…, andsyntax error at or near "x"/syntax error at end of input(42601) as the first line of a parse error.Results
LIMITwithoutORDER BY, once numbers compare by value.bun test: 1352 pass, 0 fail. rapidnative-website: all 34 CI suites as on main (test:agentneeds Supabase env locally).Known, not changed here
18.50fornumeric(10,2)/ a4.50literal, pg-mem18.5.Decimalalready tracks the scale; printing it changes the stored digit strings, which pg-mem hashes for GROUP BY / DISTINCT / unique indexes, so it needs a canonical key first. Display-only for the validator; visible in the editor later.ALTER TYPE … ADD VALUE … BEFORE/AFTERdoes not parse (none of the 120 projects uses ADD VALUE).smallintis reported asintegerin a few messages.Version 4.0.4.
🤖 Generated with Claude Code