Repository navigation
fix(postgres): type returned array elements as nullable - #12
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
ℹ️ 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,typeSchema8000 (output) and the engine'sType::json_schemanow treat an absentnullable_itemsas(T | null)[].Some(false)(array[pk],array_aggover aNOT NULLcolumn, MySQLVECTOR) still rendersT[]. - Parameters stay strict.
renderParamTypeandtypeSchema(..., input = true)are unchanged in behavior.SchemaOptionsgainsinput/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_nullableand the set-operation merge inengine/postgres/src/postgres.rsalready usedNoneto 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) = :colfortags/ints/moods, which are all one-dimensional in the seed. It also asserts that an array with aNULLelement is refused with thesrc/execute.tsTypeError. - Docs, labs and captured types. These now show
(T | null)[]. A grep ofsite/contentfound no remaining stalestring[]for Postgres arrays.
claude-opus-5-5 | 𝕏
Contributor
There was a problem hiding this comment.
✅ No new issues found. Both earlier comments are addressed.
Reviewed changes
This review covers the two commits pushed since the last Pullfrog review (7d1877d).
rowsmember array schemas allownullelements.typeSchemanow takes aninRowflag from therowscase and passes it down through nested arrays. The JSON Schema now matchesrenderParamType'sinRowbranch and thesrc/rows.tscheck, which bindsnullat every nesting level. A top-level array parameter still rejectsnullelements.- The engine schema has the same fix. In
engine/core/src/schema.rs, a newmember_schemais called only from theType::Rowscase. It makes a member's array items nullable on input, and it does this recursively. The threeengine.wasmartifacts were rebuilt. - Added tests.
tests/render.test.tschecks the TS schemas for results, parameters androwsmembers. The core schema tests check the engine'sRowsmember.node --test tests/render.test.tspasses locally (11/11). - Moved the
ROUND_TRIP_ARRAYSconst. It now sits above the JSDoc forROUND_TRIP_SQL, so that comment documents the right const again.
claude-opus-5-5 | 𝕏
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.

Postgres lets any array hold
NULLelements, whatever a column'sNOT NULLsays, and every driver returns them asnull, yet atext[]column was typedstring[]. A returned array's elements are now typed as nullable unless the statement builds the array from values it shows are notNULL; a parameter's stay strict.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'sVECTORstayT[].T[], and the run time still refuses aNULLelement, which in= any(:ids)matches nothing. So a row whose array holds aNULLgoes back in as parameters without it: a type error in TypeScript, and a refusal at run time.outputSchemafollows the result type andinputSchemathe parameter type (src/schema.ts). The engine'sType::json_schemagainsSchemaOptions::inputso its request and response schemas can follow the same split.NULLelements and asserts that the array with them is refused; S10 still checks that every driver decodes theNULLelement.Every gate in the local gate script passes on this branch, the driver matrix's local and containerized jobs included.