Skip to content

Commit 602fecd

Browse files
author
github-actions
committed
Automated dump generation
1 parent c71335a commit 602fecd

File tree

2 files changed

+81
-4
lines changed

2 files changed

+81
-4
lines changed

docs/data_model/taxonomie/functions.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ AS $function$
7676
END;
7777
$function$
7878

79-
CREATE OR REPLACE FUNCTION taxonomie.find_all_taxons_children(id integer)
79+
CREATE OR REPLACE FUNCTION taxonomie.find_all_taxons_children(ids integer[])
8080
RETURNS TABLE(cd_nom integer, cd_ref integer)
8181
LANGUAGE plpgsql
8282
IMMUTABLE
@@ -88,7 +88,7 @@ AS $function$
8888
BEGIN
8989
RETURN QUERY
9090
WITH RECURSIVE descendants AS (
91-
SELECT tx1.cd_nom, tx1.cd_ref FROM taxonomie.taxref tx1 WHERE tx1.cd_sup = id
91+
SELECT tx1.cd_nom, tx1.cd_ref FROM taxonomie.taxref tx1 WHERE tx1.cd_sup = ANY(ids)
9292
UNION ALL
9393
SELECT tx2.cd_nom, tx2.cd_ref FROM descendants d JOIN taxonomie.taxref tx2 ON tx2.cd_sup = d.cd_nom
9494
)
@@ -97,7 +97,7 @@ AS $function$
9797
END;
9898
$function$
9999

100-
CREATE OR REPLACE FUNCTION taxonomie.find_all_taxons_children(ids integer[])
100+
CREATE OR REPLACE FUNCTION taxonomie.find_all_taxons_children(id integer)
101101
RETURNS TABLE(cd_nom integer, cd_ref integer)
102102
LANGUAGE plpgsql
103103
IMMUTABLE
@@ -109,7 +109,7 @@ AS $function$
109109
BEGIN
110110
RETURN QUERY
111111
WITH RECURSIVE descendants AS (
112-
SELECT tx1.cd_nom, tx1.cd_ref FROM taxonomie.taxref tx1 WHERE tx1.cd_sup = ANY(ids)
112+
SELECT tx1.cd_nom, tx1.cd_ref FROM taxonomie.taxref tx1 WHERE tx1.cd_sup = id
113113
UNION ALL
114114
SELECT tx2.cd_nom, tx2.cd_ref FROM descendants d JOIN taxonomie.taxref tx2 ON tx2.cd_sup = d.cd_nom
115115
)
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
CREATE OR REPLACE FUNCTION utilisateurs.check_is_default_group_for_app_is_grp_and_unique(id_app integer, id_grp integer, is_default boolean)
2+
RETURNS boolean
3+
LANGUAGE plpgsql
4+
IMMUTABLE
5+
AS $function$
6+
BEGIN
7+
-- Fonction de vérification
8+
-- Test : si le role est un groupe et qu'il n'y a qu'un seul groupe par défaut définit par application
9+
IF is_default IS TRUE THEN
10+
IF (
11+
SELECT DISTINCT TRUE
12+
FROM utilisateurs.cor_role_app_profil
13+
WHERE id_application = id_app AND is_default_group_for_app IS TRUE
14+
) IS TRUE THEN
15+
RETURN FALSE;
16+
ELSIF (SELECT TRUE FROM utilisateurs.t_roles WHERE id_role = id_grp AND groupe IS TRUE) IS NULL THEN
17+
RETURN FALSE;
18+
ELSE
19+
RETURN TRUE;
20+
END IF;
21+
END IF;
22+
RETURN TRUE;
23+
END
24+
$function$
25+
26+
CREATE OR REPLACE FUNCTION utilisateurs.fct_trg_meta_dates_change()
27+
RETURNS trigger
28+
LANGUAGE plpgsql
29+
AS $function$
30+
begin
31+
if(TG_OP = 'INSERT') THEN
32+
NEW.meta_create_date = NOW();
33+
ELSIF(TG_OP = 'UPDATE') THEN
34+
NEW.meta_update_date = NOW();
35+
if(NEW.meta_create_date IS NULL) THEN
36+
NEW.meta_create_date = NOW();
37+
END IF;
38+
end IF;
39+
return NEW;
40+
end;
41+
$function$
42+
43+
CREATE OR REPLACE FUNCTION utilisateurs.get_id_role_by_name(rolename character varying)
44+
RETURNS integer
45+
LANGUAGE plpgsql
46+
IMMUTABLE
47+
AS $function$
48+
BEGIN
49+
RETURN (
50+
SELECT id_role
51+
FROM utilisateurs.t_roles
52+
WHERE nom_role = roleName
53+
);
54+
END;
55+
$function$
56+
57+
CREATE OR REPLACE FUNCTION utilisateurs.modify_date_insert()
58+
RETURNS trigger
59+
LANGUAGE plpgsql
60+
AS $function$
61+
BEGIN
62+
NEW.date_insert := now();
63+
NEW.date_update := now();
64+
RETURN NEW;
65+
END;
66+
$function$
67+
68+
CREATE OR REPLACE FUNCTION utilisateurs.modify_date_update()
69+
RETURNS trigger
70+
LANGUAGE plpgsql
71+
AS $function$
72+
BEGIN
73+
NEW.date_update := now();
74+
RETURN NEW;
75+
END;
76+
$function$
77+

0 commit comments

Comments
 (0)