Repository navigation
fix(postgres): type oid and extension types inside json as written - #85
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. One docs wording suggestion inline.
Reviewed changes
I reviewed the full diff: how Postgres writes oid, geometry and extension types inside a JSON document, in both schema writers, the renderer, the oracle's mirror and the docs.
oidinside a document is text: thejsontable insrc/render.ts, theinJsonbranch insrc/schema.tsandjson_admitsinoracle/src/seed.rsnow typeoid(and thelodomain, which resolves to it) asstring. This matchesjson_categorize_type, which writes JSON numbers only for the integer, float andnumericOIDs.geometryinside a document is GeoJSON: the type is now{ type: string; [key: string]: unknown }, with an object schema insrc/schema.tsand inengine/core/src/schema.rs. All threeengine.wasmartifacts are rebuilt for the core change.- Types with no cast to JSON are text: the built-in geometric and system types, and the listed extension types, are now
stringinstead ofunknown. The lists insrc/render.tsandjson_admitsmatch entry for entry. - Oracle case:
json_extension_typescoverslo,oid,cube,earth,seg,isbnandquery_inton CI's contrib extensions. - Docs: the Postgres page's "Values inside a document" paragraph and its examples.
I also checked two things that turned out fine:
mysqlJsoninherits the newgeometryandpointentries. That has no effect, because the MySQL engine mapsGEOMETRY(code 255) toType::Unknown, so neither name ever reaches the table.- In Rust,
oidinside a document still carriesdescription: "pg type oid", whilesrc/schema.tsgives a plain{ type: "string" }. That difference doesn't matter:Type::json_schemais only called from its own tests.
claude-opus-5-5 | 𝕏
Contributor
There was a problem hiding this comment.
✅ No new issues found. The earlier docs suggestion has been applied.
Reviewed changes
The only change since the last review is one docs sentence.
- Narrowed the extension-type rule in
site/content/docs/postgres.mdx: the sentence now says only an extension's type with no cast to JSON (e.g. pgvector'svector) is written as its text. This matches the code.geometrygoes through its own cast and comes out as GeoJSON, and an extension type that isn't in the table still rendersunknown.
claude-opus-5-5 | 𝕏
Inside a JSON document Postgres writes a number only for the integers, the floats and numeric, so an oid (and the lo domain) is its text, not a number. PostGIS writes a geometry through its cast to JSON, as GeoJSON, where the schema said a string. pgvector's, PostGIS's other types and the other extensions' with no cast to JSON are their text, which rendered unknown; they and the built-in geometric and system types are typed string there now.
colinhacks
force-pushed
the
fix-json-ext-types
branch
from
October 23, 2026 21:53
d5497b4 to
82f1d7c
Compare
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.

Inside a JSON document (
json_build_object,to_jsonb(t),json_agg), Postgres writes a value through its type's cast to JSON where one exists, a number only for the integers, the floats andnumeric, and anything else as its text. Three spellings disagreed with that:oid, and thelodomain over it, are JSON strings.json_build_object('o', 7::oid)is{"o" : "7"}, which Reylo typednumber(schemainteger). The oracle failed a case overlo/oidcolumns on 12 values. This holds with no extension involved.geometryis GeoJSON. PostGIS's cast to JSON writes{"type":"Point","coordinates":[1,2]}; the TypeScript type wasunknown(sound) but the JSON Schema saidstring. It is now{ type: string; [key: string]: unknown }with an object schema in both schema writers.vector,halfvec,sparsevec; PostGIS'sgeography,box2d,box3d,spheroid,raster;cube,seg, theisntypes,query_int,h3index,hll, the ip4r types,ulid,prefix_range, rdkit's types,roaringbitmap,semverandunitwith their ranges. These renderedunknown; they arestringnow, as are the built-in geometric and system types (point,box,pg_lsn, thereg*types).The oracle's mirror of the table (
json_admits) follows, and a new case,json_extension_types, checkslo,oid,cube,earth,seg,isbnandquery_intinside documents on CI's contrib extensions. Every type was measured on Supabase's and Neon's Postgres 17 images. The Postgres docs page's paragraph on values inside a document names the oid, geometry and extension cases.