| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Add two directives that return JSON-encoded results decoded directly into
Go structs by pgx/v5, including nested objects and arrays from a single query:
- sqlc.jsonb_build_object."Name"(key, value, ...) builds an arbitrary
named struct from key/value pairs.
- sqlc.embed.jsonb(table) builds a struct mirroring a whole row, as a
shorthand that composes inside ARRAY(...) for slices of rows.
Both are rewritten to real Postgres functions (jsonb_build_object / to_jsonb)
before analysis; pgx/v5 decodes the jsonb value into a plain struct (or slice)
with no Scan/Value plumbing.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The process_plugin_sqlc_gen_json fixture serializes the full CodeGenRequest, so adding json_fields/json_name to Column changes its output. Only codegen_json had been regenerated; this test skips locally when the sqlc-gen-json binary isn't on PATH, so CI caught it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| Back | FazBrowse Home | New Git URL |
Adds a sqlc.jsonb_build_object."Name"(key, value, ...) directive for returning JSON-shaped results that decode straight into a Go struct. It's handy for pulling a one-to-many relationship into a single query instead of running one query per parent row.
gives you:
A few notes:
Docs in docs/howto/embedding.md; covered by unit tests plus a sqlc_json golden fixture.