Repository navigation
fix(integrations): relation reads no longer round bigint and numeric array elements - #369
Conversation
Astra reviewReviewed StandardsNo merge-blocking method or YAGNI findings. The fix stays in the existing shared projection mapping rather than adding another decoder. The test helpers extract setup now used by both parity cases. The fallback for absent element metadata matches the existing snapshot schema and native-type handling, rather than adding speculative compatibility. SpecNo merge-blocking intent findings. The change preserves exact int8/numeric array elements across Checked the shared native/dev consumers, generated client typing, product documentation and distributed Postgres skill. Arrays remain VerificationRan Summary: Standards 0 blockers, none to rank; Spec 0 blockers, none to rank. |
af60cd0 to
130ebc3
Compare
18497db to
8d19388
Compare
130ebc3 to
56cb499
Compare
…nts exact Relation reads projected every array column through to_jsonb, so int8 and numeric elements became JSON numbers and were rounded, merging distinct bigint ids. The query path already returned them as exact strings. int8/numeric arrays (including domain arrays and element domains) now project through text[] before to_jsonb, keeping nulls and dimensions. Other arrays are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
8d19388 to
20ee62b
Compare
…aracter and timestamp modifiers (#370) Local Postgres fixtures dropped the source's type modifiers. A `numeric(8,2)` column became plain `numeric` under `.patchy/dev`, so inserting 9.995 read back as `"9.995"` locally but `"10.00"` from the source. `timestamp(0)` kept fractions, `character(4)` lost its padding, and `varchar(4)` accepted values the source refuses. Closes #336. Stacked on #369 (branch fix/340-array-elements). Discovery now reads each column's `atttypmod`, decodes it and stores the result as structured integers on the snapshot's column type. `numeric(8,2)` becomes `modifiers: [8, 2]`; for arrays the modifiers apply to the element. Fixture DDL and the fixture header render range-checked modifiers for numeric, varchar, bpchar, timestamp and timestamptz. For example, `"pg_catalog"."numeric"(8,2)` or `"pg_catalog"."timestamptz"(3)[]`. The source's formatted type string is still never executed. A modifier that fails validation excludes the column as `unsupported_type`. Domains still resolve to their base type without their own modifiers, and the schema-drift check still compares types without modifiers. Snapshots discovered before this change carry no modifiers until they are rediscovered. The snapshot schema change is in `docs/API.md`. `docs/product.md` and the `patchy-postgres` project skill now describe the new fixture types. Tests: - New `Parity.test.ts` case runs the same reads natively and against the dev fixture over `numeric(8,2)`, `numeric(4)`, `timestamp(0)`, `timestamptz(3)`, `character(4)`, `varchar(4)` and `numeric(8,2)[]`. It failed on the base branch with the values the issue reports and passes now. It also checks that an over-length `varchar(4)` fixture row is refused locally with SQLSTATE 22001. - New `Mapping.test.ts` case covers decoding (including a negative numeric scale), rendering, rejected modifiers and the unchanged drift check. - `pnpm typecheck` and `pnpm lint` pass. On a loaded machine, `pnpm test` had 959 passed and 2 failed, both 5-second timeouts (`Operations.test.ts`, `Runtime.test.ts`). Re-run alone, both files pass. Implemented by Claude Opus 5.5 via Claude Code (foreman run orchestrated by Claude Fable 5.1).
Stacked on #368 (branch fix/341-bfcache).
Fixes #340. Postgres relation reads (
list,get,getMany) roundedbigint[]andnumeric[]elements, so two distinct external ids like9007199254740992and9007199254740993came back equal.queryon the same columns already returned them exactly, as strings.The relation mapping projected every array through
to_jsonb, which turns elements into JSON numbers. Arrays whose element is int8 or numeric now go throughtext[]first, so elements arrive as strings, matching the scalar and query paths. Nulls and dimensions are kept, domain arrays and arrays of int8/numeric domains are covered, and older snapshots without element metadata fall back to the builtin array name. Other arrays (such asinteger[]) still return numbers. The postgres skill anddocs/product.mdnow say array elements of int8/numeric are strings.Tests:
bigint[],numeric[](with a null), an int8-domain array, a domain overbigint[], a 2-Dbigint[]and aninteger[]control, then checks list/get/getMany against query on both native Postgres and the PGlite dev fixture. It failed on the unmodified code with the ticket's exact rounding, on each surface separately.pnpm typecheckandpnpm lintpass. The integrations suite passes. The fullpnpm testhad 4 timeouts under machine load (Operations, Runtime, PgliteCompanyDatabases); those files pass when run alone.Implemented by Claude Opus 5.5 via Claude Code (foreman run orchestrated by Claude Fable 5.1).