Skip to content

Commit 96c8ac7

Browse files
committed
chore: reduce functions changes to minimum
1 parent 2ba4a18 commit 96c8ac7

File tree

1 file changed

+19
-30
lines changed

1 file changed

+19
-30
lines changed

src/lib/sql/functions.sql.ts

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -121,45 +121,34 @@ from
121121
select
122122
oid,
123123
jsonb_agg(jsonb_build_object(
124-
'mode', mode,
124+
'mode', t2.mode,
125125
'name', name,
126126
'type_id', type_id,
127127
'has_default', has_default
128128
)) as args
129129
from
130130
(
131131
select
132-
t1.oid,
133-
t2.mode,
134-
t1.name,
135-
t1.type_id,
136-
t1.has_default
132+
oid,
133+
unnest(arg_modes) as mode,
134+
unnest(arg_names) as name,
135+
unnest(arg_types)::int8 as type_id,
136+
unnest(arg_has_defaults) as has_default
137137
from
138-
(
139-
select
140-
oid,
141-
unnest(arg_modes) as mode,
142-
unnest(arg_names) as name,
143-
unnest(arg_types)::int8 as type_id,
144-
unnest(arg_has_defaults) as has_default
145-
from
146-
functions
147-
) as t1
148-
cross join lateral (
149-
select
150-
case
151-
when t1.mode = 'i' then 'in'
152-
when t1.mode = 'o' then 'out'
153-
when t1.mode = 'b' then 'inout'
154-
when t1.mode = 'v' then 'variadic'
155-
else 'table'
156-
end as mode
157-
) as t2
158-
left join pg_type pt on pt.oid = t1.type_id
159-
order by t1.name asc
160-
) sub
138+
functions
139+
) as t1,
140+
lateral (
141+
select
142+
case
143+
when t1.mode = 'i' then 'in'
144+
when t1.mode = 'o' then 'out'
145+
when t1.mode = 'b' then 'inout'
146+
when t1.mode = 'v' then 'variadic'
147+
else 'table'
148+
end as mode
149+
) as t2
161150
group by
162-
oid
151+
t1.oid
163152
) f_args on f_args.oid = f.oid
164153
${props.limit ? `limit ${props.limit}` : ''}
165154
${props.offset ? `offset ${props.offset}` : ''}

0 commit comments

Comments
 (0)