12 lines
376 B
Plaintext
12 lines
376 B
Plaintext
create or replace function struct_merge_patch(base, update) as (
|
|
<syntaxhighlight lang="sql">
|
|
with cte as (
|
|
from (select unnest(update))
|
|
positional join
|
|
(select COLUMNS(x -> x not in json_keys(update::JSON)) from (select unnest(base)))
|
|
)
|
|
select cte from cte
|
|
);
|
|
|
|
select struct_merge_patch( getvariable('base'), getvariable('update')) as merged;
|