Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 6 additions & 3 deletions src/lib/sql/functions.sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,13 @@ from
(
select
oid,
(string_to_array(unnest(proconfig), '='))[1] as param,
(string_to_array(unnest(proconfig), '='))[2] as value
split_part(cfg, '=', 1) as param,
-- Keep everything after the first '=', so values like application_name=api=worker
-- round-trip intact (string_to_array(...)[2] truncates at the next '=').
substring(cfg from position('=' in cfg) + 1) as value
from
functions
functions,
lateral unnest(proconfig) as cfg
) as t
group by
oid
Expand Down
20 changes: 20 additions & 0 deletions test/lib/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,3 +531,23 @@ test('retrieve function by args filter - function with no arguments', async () =
})
expect(res.error).toBeNull()
})

test('config_params preserves equals signs in values', async () => {
await pgMeta.query(`
create or replace function public.config_equals_test()
returns void
language sql
set application_name to 'api=worker'
as $$ select 1; $$;
`)

const res = await pgMeta.functions.retrieve({
schema: 'public',
name: 'config_equals_test',
args: [],
})
expect(res.error).toBeNull()
expect(res.data?.config_params).toEqual({ application_name: 'api=worker' })

await pgMeta.query(`drop function public.config_equals_test();`)
})