Skip to content

Commit

Permalink
Merge pull request #3857 from mathesar-foundation/patch_record_via_st…
Browse files Browse the repository at this point in the history
…ring_pk

Allow patching records via string pks
  • Loading branch information
Anish9901 authored Sep 26, 2024
2 parents 5cae65f + 490dd43 commit 9ca1e22
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion db/sql/00_msar.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5098,10 +5098,11 @@ FROM jsonb_each_text(rec_def);
$$ LANGUAGE SQL STABLE RETURNS NULL ON NULL INPUT;


DROP FUNCTION IF EXISTS msar.patch_record_in_table(oid, anyelement, jsonb, boolean);
CREATE OR REPLACE FUNCTION
msar.patch_record_in_table(
tab_id oid,
rec_id anyelement,
rec_id anycompatible,
rec_def jsonb,
return_record_summaries boolean DEFAULT false
) RETURNS jsonb AS $$/*
Expand Down
18 changes: 18 additions & 0 deletions db/sql/test_00_msar.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4259,6 +4259,24 @@ END;
$$ LANGUAGE plpgsql;


CREATE OR REPLACE FUNCTION test_patch_record_in_table_string_pk() RETURNS SETOF TEXT AS $$
DECLARE
rel_id oid;
BEGIN
PERFORM __setup_add_record_table();
rel_id := 'atable'::regclass::oid;
RETURN NEXT is(
msar.patch_record_in_table( rel_id, '2', '{"2": 10}'),
$p${
"results": [{"1": 2, "2": 10, "3": "sdflfflsk", "4": null, "5": [1, 2, 3, 4]}],
"linked_record_summaries": null,
"record_summaries": null
}$p$
);
END;
$$ LANGUAGE plpgsql;


CREATE OR REPLACE FUNCTION test_patch_record_in_table_multi() RETURNS SETOF TEXT AS $$
DECLARE
rel_id oid;
Expand Down

0 comments on commit 9ca1e22

Please sign in to comment.