Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
64a1afc
feat(typegen): add setof function type introspection
avallete Jul 15, 2025
1bd2b30
Merge branch 'master' into feat/add-functions-setof-type-introspectio…
avallete Aug 6, 2025
3bb1b45
chore: update snapshots
avallete Aug 6, 2025
6b8c753
chore: unify sort and dedup loops
avallete Aug 6, 2025
c22c830
chore: remove duplicate sort
avallete Aug 6, 2025
529ac02
Merge branch 'master' into feat/add-functions-setof-type-introspectio…
avallete Sep 16, 2025
fb11ed8
chore: include view in type
avallete Sep 16, 2025
d6626b4
fix: isOneToOne
avallete Sep 16, 2025
6b251d6
fix: tests
avallete Sep 16, 2025
f1f2391
Merge branch 'master' into feat/add-functions-setof-type-introspectio…
avallete Sep 16, 2025
1e4daa0
Merge branch 'master' into feat/add-functions-setof-type-introspectio…
avallete Sep 17, 2025
da46bf6
chore: dedup typescript typegen logic
avallete Sep 24, 2025
8429509
Merge branch 'chore/isolate-function-type-generation' into feat/add-f…
avallete Sep 24, 2025
f8bbfca
chore: re-use generateColumn
avallete Sep 24, 2025
445f1ff
fix: retrieve prorows only
avallete Sep 24, 2025
5d002df
chore: refactor typegen for prorows only
avallete Sep 24, 2025
a5ea005
fix: only get reltype in types
avallete Sep 24, 2025
2ba4a18
chore: reuse relationTypeByIds
avallete Sep 24, 2025
96c8ac7
chore: reduce functions changes to minimum
avallete Sep 24, 2025
89b5561
chore: only single loop for types
avallete Sep 24, 2025
e73b3b9
chore: single sort for relationships
avallete Sep 24, 2025
59efa8c
chore: reduce loops
avallete Sep 24, 2025
26265dd
Merge branch 'chore/isolate-function-type-generation' into feat/add-f…
avallete Sep 24, 2025
d1e3ad9
fix: relationtype setof functions generation
avallete Sep 27, 2025
32e789f
chore: fix prettier
avallete Sep 27, 2025
cfb405f
chore: update snapshots
avallete Sep 27, 2025
8824a5a
chore: fix types test
avallete Sep 27, 2025
f8321c6
fix: test types
avallete Sep 27, 2025
0262ebc
fix: include materializedView types
avallete Sep 29, 2025
bc81acd
test: add search_todos_by_details function
avallete Sep 30, 2025
40c06b8
fix: add setof from * for all relation functions
avallete Sep 30, 2025
12217b2
Merge branch 'master' into feat/add-functions-setof-type-introspectio…
avallete Oct 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20 as build
FROM node:20 AS build
WORKDIR /usr/src/app
# Do `npm ci` separately so we can cache `node_modules`
# https://nodejs.org/en/docs/guides/nodejs-docker-webapp/
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"gen:types:go": "PG_META_GENERATE_TYPES=go node --loader ts-node/esm src/server/server.ts",
"gen:types:swift": "PG_META_GENERATE_TYPES=swift node --loader ts-node/esm src/server/server.ts",
"start": "node dist/server/server.js",
"dev": "trap 'npm run db:clean' INT && run-s db:clean db:run && nodemon --exec node --loader ts-node/esm src/server/server.ts | pino-pretty --colorize",
"dev": "trap 'npm run db:clean' INT && run-s db:clean db:run && run-s dev:code",
"dev:code": "nodemon --exec node --loader ts-node/esm src/server/server.ts | pino-pretty --colorize",
"test": "run-s db:clean db:run test:run db:clean",
"db:clean": "cd test/db && docker compose down",
"db:run": "cd test/db && docker compose up --detach --wait",
Expand Down
4 changes: 4 additions & 0 deletions src/lib/sql/functions.sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ select
pg_get_function_result(f.oid) as return_type,
nullif(rt.typrelid::int8, 0) as return_type_relation_id,
f.proretset as is_set_returning_function,
case
when f.proretset then nullif(f.prorows, 0)
else null
end as prorows,
case
when f.provolatile = 'i' then 'IMMUTABLE'
when f.provolatile = 's' then 'STABLE'
Expand Down
5 changes: 3 additions & 2 deletions src/lib/sql/types.sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ select
format_type (t.oid, null) as format,
coalesce(t_enums.enums, '[]') as enums,
coalesce(t_attributes.attributes, '[]') as attributes,
obj_description (t.oid, 'pg_type') as comment
obj_description (t.oid, 'pg_type') as comment,
nullif(t.typrelid::int8, 0) as type_relation_id
from
pg_type t
left join pg_namespace n on n.oid = t.typnamespace
Expand Down Expand Up @@ -46,7 +47,7 @@ from
t.typrelid = 0
or (
select
c.relkind ${props.includeTableTypes ? `in ('c', 'r')` : `= 'c'`}
c.relkind ${props.includeTableTypes ? `in ('c', 'r', 'v', 'm')` : `= 'c'`}
from
pg_class c
where
Expand Down
2 changes: 2 additions & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ const postgresFunctionSchema = Type.Object({
return_type: Type.String(),
return_type_relation_id: Type.Union([Type.Integer(), Type.Null()]),
is_set_returning_function: Type.Boolean(),
prorows: Type.Union([Type.Number(), Type.Null()]),
behavior: Type.Union([
Type.Literal('IMMUTABLE'),
Type.Literal('STABLE'),
Expand Down Expand Up @@ -442,6 +443,7 @@ export const postgresTypeSchema = Type.Object({
enums: Type.Array(Type.String()),
attributes: Type.Array(Type.Object({ name: Type.String(), type_id: Type.Integer() })),
comment: Type.Union([Type.String(), Type.Null()]),
type_relation_id: Type.Union([Type.Integer(), Type.Null()]),
})
export type PostgresType = Static<typeof postgresTypeSchema>

Expand Down
Loading