File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed
packages/database/supabase Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 1- ALTER TABLE " public" ." Concept" DROP COLUMN " arity" ;
2-
3- ALTER TABLE " public" ." Concept" ADD COLUMN " arity" smallint GENERATED ALWAYS AS (compute_arity_local(schema_id, literal_content)) STORED;
4-
51CREATE OR REPLACE FUNCTION public .compute_arity_id(p_schema_id bigint )
62RETURNS smallint
73LANGUAGE sql
84IMMUTABLE
95AS $function$
10- WITH q AS ( SELECT jsonb_path_query( literal_content, ' $. roles[*] ' ) FROM public." Concept" WHERE id= p_schema_id) SELECT count ( * ) FROM q ;
6+ SELECT COALESCE(jsonb_array_length( literal_content- > ' roles' ), 0 ) FROM public." Concept" WHERE id= p_schema_id;
117$function$;
128
139CREATE OR REPLACE FUNCTION public .compute_arity_lit(lit_content jsonb)
1410RETURNS smallint
1511LANGUAGE sql
1612IMMUTABLE
1713AS $function$
18- WITH q AS ( SELECT jsonb_path_query( lit_content, ' $. roles[*] ' )) SELECT count ( * ) FROM q ;
14+ SELECT COALESCE(jsonb_array_length( lit_content- > ' roles' ), 0 ) ;
1915$function$;
2016
2117CREATE OR REPLACE FUNCTION public .compute_arity_local(schema_id bigint , lit_content jsonb)
@@ -26,6 +22,10 @@ AS $function$
2622 SELECT CASE WHEN schema_id IS NULL THEN compute_arity_lit(lit_content) ELSE compute_arity_id(schema_id) END;
2723$function$;
2824
25+ ALTER TABLE " public" ." Concept" DROP COLUMN " arity" ;
26+
27+ ALTER TABLE " public" ." Concept" ADD COLUMN " arity" smallint GENERATED ALWAYS AS (compute_arity_local(schema_id, literal_content)) STORED;
28+
2929CREATE OR REPLACE FUNCTION public .extract_references(refs jsonb)
3030RETURNS bigint []
3131LANGUAGE sql
Original file line number Diff line number Diff line change @@ -17,12 +17,12 @@ CREATE OR REPLACE FUNCTION extract_references(refs JSONB) RETURNS BIGINT [] LANG
1717$$;
1818
1919CREATE OR REPLACE FUNCTION compute_arity_lit (lit_content JSONB) RETURNS smallint language sql IMMUTABLE AS $$
20- WITH q AS ( SELECT jsonb_path_query( lit_content, ' $. roles[*] ' )) SELECT count ( * ) FROM q ;
20+ SELECT COALESCE(jsonb_array_length( lit_content- > ' roles' ), 0 ) ;
2121$$;
2222
2323SET check_function_bodies = false;
2424CREATE OR REPLACE FUNCTION compute_arity_id (p_schema_id BIGINT ) RETURNS smallint language sql IMMUTABLE AS $$
25- WITH q AS ( SELECT jsonb_path_query( literal_content, ' $. roles[*] ' ) FROM public." Concept" WHERE id= p_schema_id) SELECT count ( * ) FROM q ;
25+ SELECT COALESCE(jsonb_array_length( literal_content- > ' roles' ), 0 ) FROM public." Concept" WHERE id= p_schema_id;
2626$$;
2727SET check_function_bodies = true;
2828
You can’t perform that action at this time.
0 commit comments