Add ltree_plruby: TRANSFORM FOR TYPE ltree#4
Merged
Conversation
A new companion extension (ltree_plruby/) providing TRANSFORM FOR TYPE
ltree, mirroring the in-core ltree_plpython transform (ltree <-> list).
An opted-in function receives an ltree argument as a Ruby Array of its
label Strings ('Top.Science' -> ['Top','Science']) and may return an
Array of labels into an ltree result (elements stringified and joined
with '.', so an invalid label is rejected by ltree's own parser). The
empty ltree maps to the empty Array; a NULL ltree is nil.
Like hstore_plruby, it never touches ltree's internal representation:
it converts through ltree's public ltree2text(ltree)/text2ltree(text)
functions, resolved at run time via the pg_transform row that points at
the transform function (schema/search_path independent) and cached in
fn_extra. So it needs no ltree headers and works with the packaged ltree
on PG 11-18.
New ltree_plruby regression suite (arg->Array, path ops, build/round-trip,
empty and NULL, non-Array rejection, SETOF/composite via return_next,
trigger $_TD + MODIFY, untransformed passthrough). Wired into CI beside
the jsonb/hstore transforms; INSTALL/README/docs updated. Green on PG 12
and 18.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
eed2cd0 to
36929d0
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.
Summary
New companion extension
ltree_plrubyprovidingTRANSFORM FOR TYPE ltree, closing the last identified PL/Python parity gap (mirrors the in-coreltree_plpythontransform,ltree↔ list).An opted-in function receives an
ltreeargument as a RubyArrayof its label Strings —'Top.Science.Astronomy'→['Top', 'Science', 'Astronomy']— and may return anArrayof labels into anltreeresult (elements stringified and joined with., so an invalid label is rejected by ltree's own parser). The empty ltree maps to the emptyArray; a NULL ltree isnil.Design
Follows the
hstore_plrubypattern exactly: it never touches ltree's internal representation. It converts through ltree's publicltree2text(ltree)/text2ltree(text)functions, resolved at run time via thepg_transformrow that points at the transform function (schema/search_pathindependent) and cached infn_extra. So it needs no ltree headers and works with the packaged ltree on PG 11–18.Testing
New
ltree_plrubyregression suite: argument →Array, path operations (length/parent/reverse), build & round-trip, empty and NULL, non-Arrayrejection (clean error),SETOF/composite rows viareturn_next, trigger$_TDArray+'MODIFY', and untransformed passthrough (still aString). Green on PG 12 and PG 18; wired into CI beside the jsonb/hstore transforms.INSTALL,README, and the language reference updated. Additive; no compatibility impact.🤖 Generated with Claude Code