8000 fix(postgres): type returned array elements as nullable by colinhacks · Pull Request #12 · colinhacks/reylo · GitHub
[go: up one dir, main page]

Skip to content

fix(postgres): type returned array elements as nullable - #12

Merged
colinhacks merged 4 commits into
mainfrom
array-null-elements
Oct 22, 2026
Merged

colinhacks merged 4 commits into
mainfrom
array-null-elements

Conversation

@colinhacks
Copy link
Copy Markdown
Owner

Postgres lets any array hold NULL elements, whatever a column's NOT NULL says, and every driver returns them as null, yet a text[] column was typed string[]. A returned array's elements are now typed as nullable unless the statement builds the array from values it shows are not NULL; a parameter's stay strict.

  • A text[] column reads (string | null)[], and so does an array the engine says nothing about (ARRAY(SELECT …), a function's). An array the statement builds from non-null values (array[id] over a primary key) and MySQL's VECTOR stay T[].
  • An array parameter stays T[], and the run time still refuses a NULL element, which in = any(:ids) matches nothing. So a row whose array holds a NULL goes back in as parameters without it: a type error in TypeScript, and a refusal at run time.
  • outputSchema follows the result type and inputSchema the parameter type (src/schema.ts). The engine's Type::json_schema gains SchemaOptions::input so its request and response schemas can follow the same split.
  • The driver matrix's S11 round trip sends each array back without its NULL elements and asserts that the array with them is refused; S10 still checks that every driver decodes the NULL element.
  • Updates the labs' exact types, the Postgres docs and the docs' captured types.

Every gate in the local gate script passes on this branch, the driver matrix's local and containerized jobs included.

@vercel
vercel Bot commented Oct 22, 2026 •
Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
reylo Ready Ready Preview Oct 22, 2026 5:39pm UTC

Request Review

Copilot AI balanced review requested due to automatic review settings October 22, 2026 17:15
Copilot AI left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@pullfrog pullfrog Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues. Two rough edges, both minor, are noted inline.

Reviewed changes

I reviewed the single commit that makes returned Postgres array elements nullable by default and keeps array parameters strict.

  • Result arrays default to nullable. renderType, typeSchema 8000 (output) and the engine's Type::json_schema now treat an absent nullable_items as (T | null)[]. Some(false) (array[pk], array_agg over a NOT NULL column, MySQL VECTOR) still renders T[].
  • Parameters stay strict. renderParamType and typeSchema(..., input = true) are unchanged in behavior. SchemaOptions gains input / as_input() so the engine's schema can make the same split. It has no caller in this repo outside the tests.
  • Inference untouched. items_nullable and the set-operation merge in engine/postgres/src/postgres.rs already used None to mean "unknown", so the new default is the sound reading of what they emit. The oracle's checks already treated an absent value as nullable.
  • Driver matrix S11. The round trip now compares array_remove(col, null) = :col for tags / ints / moods, which are all one-dimensional in the seed. It also asserts that an array with a NULL element is refused with the src/execute.ts TypeError.
  • Docs, labs and captured types. These now show (T | null)[]. A grep of site/content found no remaining stale string[] for Postgres arrays.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

Comment thread src/schema.ts Resolved
Comment thread lab/driver-matrix/lib/harness.ts Resolved
@pullfrog pullfrog Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found. Both earlier comments are addressed.

Reviewed changes

This review covers the two commits pushed since the last Pullfrog review (7d1877d).

  • rows member array schemas allow null elements. typeSchema now takes an inRow flag from the rows case and passes it down through nested arrays. The JSON Schema now matches renderParamType's inRow branch and the src/rows.ts check, which binds null at every nesting level. A top-level array parameter still rejects null elements.
  • The engine schema has the same fix. In engine/core/src/schema.rs, a new member_schema is called only from the Type::Rows case. It makes a member's array items nullable on input, and it does this recursively. The three engine.wasm artifacts were rebuilt.
  • Added tests. tests/render.test.ts checks the TS schemas for results, parameters and rows members. The core schema tests check the engine's Rows member. node --test tests/render.test.ts passes locally (11/11).
  • Moved the ROUND_TRIP_ARRAYS const. It now sits above the JSDoc for ROUND_TRIP_SQL, so that comment documents the right const again.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@colinhacks
colinhacks merged commit 7de25a3 into main Oct 22, 2026
4 checks passed
@colinhacks
colinhacks deleted the array-null-elements branch October 22, 2026 17:41
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.

2 participants

0