Remove Mutable entities

This commit is contained in:
2020-12-15 14:15:11 +01:00
parent 9d208292a5
commit c2c8b91dc5
20 changed files with 85 additions and 210 deletions

View File

@@ -8,7 +8,7 @@ create schema if not exists public;
create table if not exists test
(
id serial not null
id uuid not null
constraint test_pk
primary key,
name text
@@ -16,24 +16,24 @@ create table if not exists test
create table if not exists test2
(
id serial not null,
id uuid not null,
title text,
test_id integer
test_id uuid
constraint test2_test_id_fk
references test
);
INSERT INTO test (id, name) VALUES (1, 'plop') ON CONFLICT DO NOTHING;
INSERT INTO test2 (id, title, test_id) VALUES (1, 'plop', 1) ON CONFLICT DO NOTHING;
INSERT INTO test2 (id, title, test_id) VALUES (2, 'plip', 1) ON CONFLICT DO NOTHING;
INSERT INTO test2 (id, title, test_id) VALUES (3, 'ttt', null) ON CONFLICT DO NOTHING;
INSERT INTO test (id, name) VALUES ('1e5f5d41-6d14-4007-897b-0ed2616bec96', 'plop') ON CONFLICT DO NOTHING;
INSERT INTO test2 (id, title, test_id) VALUES ('1e5f5d41-6d14-4007-897b-0ed2616bec96', 'plop', '1e5f5d41-6d14-4007-897b-0ed2616bec96') ON CONFLICT DO NOTHING;
INSERT INTO test2 (id, title, test_id) VALUES ('829b1a29-5db8-47f9-9562-961c561ac528', 'plip', '1e5f5d41-6d14-4007-897b-0ed2616bec96') ON CONFLICT DO NOTHING;
INSERT INTO test2 (id, title, test_id) VALUES ('457daad5-4f1b-4eb7-80ec-6882adb8cc7d', 'ttt', null) ON CONFLICT DO NOTHING;
CREATE OR REPLACE FUNCTION test_function (name text default 'plop', IN hi text default 'hello', out result json)
LANGUAGE plpgsql
AS
$$
BEGIN
result = json_build_object('id', 3, 'name', name);
result = json_build_object('id', '457daad5-4f1b-4eb7-80ec-6882adb8cc7d', 'name', name);
END;
$$;
@@ -44,8 +44,8 @@ AS
$$
BEGIN
result = json_build_array(
json_build_object('id', 3, 'name', name),
json_build_object('id', 4, 'name', hi)
json_build_object('id', '457daad5-4f1b-4eb7-80ec-6882adb8cc7d', 'name', name),
json_build_object('id', '8d20abb0-7f77-4b6c-9991-44acd3c88faa', 'name', hi)
);
END;
$$;
@@ -56,8 +56,8 @@ AS
$$
BEGIN
SELECT json_build_array(
json_build_object('id', 3, 'name', name::text),
json_build_object('id', 4, 'name', name::text || '-2')
json_build_object('id', '457daad5-4f1b-4eb7-80ec-6882adb8cc7d', 'name', name::text),
json_build_object('id', '8d20abb0-7f77-4b6c-9991-44acd3c88faa', 'name', name::text || '-2')
),
10
INTO result, total
@@ -70,7 +70,7 @@ CREATE OR REPLACE FUNCTION test_function_object (inout resource json)
AS
$$
BEGIN
resource = json_build_object('id', 1, 'name', 'changedName');
resource = json_build_object('id', '1e5f5d41-6d14-4007-897b-0ed2616bec96', 'name', 'changedName');
END;
$$;

View File

@@ -3,6 +3,6 @@ LANGUAGE plpgsql
AS
$$
BEGIN
result = json_build_object('id', 3, 'name', name);
result = json_build_object('id', '457daad5-4f1b-4eb7-80ec-6882adb8cc7d', 'name', name);
END;
$$

View File

@@ -3,6 +3,6 @@ LANGUAGE plpgsql
AS
$$
BEGIN
resource = json_build_object('id', 1, 'name', 'changedName');
resource = json_build_object('id', '1e5f5d41-6d14-4007-897b-0ed2616bec96', 'name', 'changedName');
END;
$$

View File

@@ -4,8 +4,8 @@ AS
$$
BEGIN
result = json_build_array(
json_build_object('id', 3, 'name', name),
json_build_object('id', 4, 'name', hi)
json_build_object('id', '457daad5-4f1b-4eb7-80ec-6882adb8cc7d', 'name', name),
json_build_object('id', '8d20abb0-7f77-4b6c-9991-44acd3c88faa', 'name', hi)
);
END;
$$

View File

@@ -4,8 +4,8 @@ AS
$$
BEGIN
SELECT json_build_array(
json_build_object('id', 3, 'name', name::text),
json_build_object('id', 4, 'name', name::text || '-2')
json_build_object('id', '457daad5-4f1b-4eb7-80ec-6882adb8cc7d', 'name', name::text),
json_build_object('id', '8d20abb0-7f77-4b6c-9991-44acd3c88faa', 'name', name::text || '-2')
),
10
INTO result, total

View File

@@ -3,6 +3,6 @@ CREATE OR REPLACE FUNCTION test_function_duplicate (name text default 'plop') re
AS
$$
BEGIN
return json_build_object('id', 3, 'name', name);
return json_build_object('id', '457daad5-4f1b-4eb7-80ec-6882adb8cc7d', 'name', name);
END;
$$

View File

@@ -1 +1 @@
select json_build_object('id', 2, 'name', 'test');
select json_build_object('id', '829b1a29-5db8-47f9-9562-961c561ac528', 'name', 'test');

View File

@@ -1 +1 @@
select json_build_object('id', 2, 'name', :name::text), 'plop'::text as other;
select json_build_object('id', '829b1a29-5db8-47f9-9562-961c561ac528', 'name', :name::text), 'plop'::text as other;

View File

@@ -1,5 +1,5 @@
SELECT json_build_array(
json_build_object('id', 3, 'name', :name::text),
json_build_object('id', 4, 'name', :name::text || '-2')
json_build_object('id', '457daad5-4f1b-4eb7-80ec-6882adb8cc7d', 'name', :name::text),
json_build_object('id', '6085c12e-e94d-4ae1-b7ad-23acc7a82a98', 'name', :name::text || '-2')
), 10 as total
LIMIT :limit OFFSET :offset