Skip to content

Add composite type support#190

Merged
SeanTAllen merged 1 commit intomainfrom
add-composite-type-support
Apr 4, 2026
Merged

Add composite type support#190
SeanTAllen merged 1 commit intomainfrom
add-composite-type-support

Conversation

@SeanTAllen
Copy link
Copy Markdown
Member

@SeanTAllen SeanTAllen commented Apr 4, 2026

User-defined composite types (CREATE TYPE ... AS (...)) can now be decoded as PgComposite in query results and sent as query parameters. Register composite types with CodecRegistry.with_composite_type() providing the OID and field descriptors (name/OID pairs).

Both PreparedQuery (binary format) and SimpleQuery (text format) decode registered composites. Nested composites and composite arrays are supported. Depth-guarded recursion prevents stack overflow from pathological schemas.

New files:

  • pg_composite.ponyPgComposite val class with positional/named field access and from_fields convenience constructor
  • _composite_encoder.pony — binary composite wire format encoder
  • _test_composite.pony — 57 unit tests + 3 integration tests
  • examples/composite-type/ — two-phase OID discovery example

Design: #188

@SeanTAllen SeanTAllen added the changelog - added Automatically add "Added" CHANGELOG entry on merge label Apr 4, 2026
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Apr 4, 2026
User-defined composite types (CREATE TYPE ... AS) can now be decoded as
PgComposite in query results and sent as query parameters. Register
composite types with CodecRegistry.with_composite_type() providing
the OID and field descriptors (name/OID pairs).

Both PreparedQuery (binary format) and SimpleQuery (text format) decode
registered composites. Nested composites and composite arrays are
supported. Depth-guarded recursion prevents stack overflow from
pathological schemas.

PgComposite.from_fields provides a safe construction API for query
parameters — each field's name, OID, and value stay together,
eliminating the misalignment risk of parallel arrays.

Design: #188
@SeanTAllen SeanTAllen force-pushed the add-composite-type-support branch from cbf9fff to 32bfb39 Compare April 4, 2026 18:31
@SeanTAllen SeanTAllen merged commit 8f0db65 into main Apr 4, 2026
8 checks passed
@SeanTAllen SeanTAllen deleted the add-composite-type-support branch April 4, 2026 18:43
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Apr 4, 2026
github-actions bot pushed a commit that referenced this pull request Apr 4, 2026
github-actions bot pushed a commit that referenced this pull request Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog - added Automatically add "Added" CHANGELOG entry on merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants