removes logging from jsonb-changes-delta
This commit is contained in:
parent
d0b201aff9
commit
a7f669a1f9
@ -17,8 +17,6 @@ declare
|
|||||||
diffJson jsonb;
|
diffJson jsonb;
|
||||||
oldJsonElement record;
|
oldJsonElement record;
|
||||||
begin
|
begin
|
||||||
raise notice '>>> diffing: % % vs. % %', jsonb_typeof(oldJson), oldJson, jsonb_typeof(newJson), newJson;
|
|
||||||
|
|
||||||
if oldJson is null or jsonb_typeof(oldJson) = 'null' or
|
if oldJson is null or jsonb_typeof(oldJson) = 'null' or
|
||||||
newJson is null or jsonb_typeof(newJson) = 'null' then
|
newJson is null or jsonb_typeof(newJson) = 'null' then
|
||||||
return newJson;
|
return newJson;
|
||||||
@ -27,26 +25,18 @@ begin
|
|||||||
diffJson = newJson;
|
diffJson = newJson;
|
||||||
for oldJsonElement in select * from jsonb_each(oldJson)
|
for oldJsonElement in select * from jsonb_each(oldJson)
|
||||||
loop
|
loop
|
||||||
raise notice 'intermediate result: %', diffJson;
|
|
||||||
raise notice 'record: %', oldJsonElement;
|
|
||||||
if diffJson @> jsonb_build_object(oldJsonElement.key, oldJsonElement.value) then
|
if diffJson @> jsonb_build_object(oldJsonElement.key, oldJsonElement.value) then
|
||||||
raise notice 'ignoring equal: %', oldJsonElement.key;
|
|
||||||
diffJson = diffJson - oldJsonElement.key;
|
diffJson = diffJson - oldJsonElement.key;
|
||||||
elsif diffJson ? oldJsonElement.key then
|
elsif diffJson ? oldJsonElement.key then
|
||||||
if jsonb_typeof(newJson -> (oldJsonElement.key)) = 'object' then
|
if jsonb_typeof(newJson -> (oldJsonElement.key)) = 'object' then
|
||||||
raise notice 'diffing new: % -> %', oldJsonElement.key, newJson -> (oldJsonElement.key);
|
|
||||||
diffJson = diffJson ||
|
diffJson = diffJson ||
|
||||||
jsonb_build_object(oldJsonElement.key,
|
jsonb_build_object(oldJsonElement.key,
|
||||||
jsonb_changes_delta(oldJsonElement.value, newJson -> (oldJsonElement.key)));
|
jsonb_changes_delta(oldJsonElement.value, newJson -> (oldJsonElement.key)));
|
||||||
else
|
|
||||||
raise notice 'not an object: %, leaving %', oldJsonElement.key, newJson -> (oldJsonElement.key);
|
|
||||||
end if;
|
end if;
|
||||||
else
|
else
|
||||||
raise notice 'nulling old: %', oldJsonElement.key;
|
|
||||||
diffJson = diffJson || jsonb_build_object(oldJsonElement.key, null);
|
diffJson = diffJson || jsonb_build_object(oldJsonElement.key, null);
|
||||||
end if;
|
end if;
|
||||||
end loop;
|
end loop;
|
||||||
raise notice '<<< result: %', diffJson;
|
|
||||||
return diffJson;
|
return diffJson;
|
||||||
end; $$;
|
end; $$;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user