Skip to content

Add function to fill the contextes_projets table - #2

Open
Elioooooott wants to merge 6 commits into
3liz:mainfrom
Elioooooott:fill-project-contexts
Open

Add function to fill the contextes_projets table#2
Elioooooott wants to merge 6 commits into
3liz:mainfrom
Elioooooott:fill-project-contexts

Conversation

@Elioooooott

Copy link
Copy Markdown
Contributor
  • Add function to fill the contextes_projets table with the contexts that intersect with the project
  • Replace the "cree_par" and "modifie_par" columns with "login"
  • Fix the SQL function for importing context data and add type validation

Replace useless column "cree_par" "modifie_par" by "login" .
Add data type verification to the function "import_data_from_temporary_table".
@Elioooooott
Elioooooott requested a review from mdouchin August 7, 2026 07:06
@Elioooooott
Elioooooott force-pushed the fill-project-contexts branch from ebe2fc3 to e4b9c75 Compare August 10, 2026 09:48
@Elioooooott
Elioooooott marked this pull request as ready for review August 31, 2026 08:22

@mdouchin mdouchin left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Small changes needed

Comment on lines +58 to +79
EXECUTE format(
$SQL$
INSERT INTO desimper.contextes_projets
(fk_id_projet, geom, code_contexte, id_objet_contexte, surface_m, login)
SELECT
$1,
ST_Multi(ST_CollectionExtract(ST_MakeValid(valid_contexts.geom), 3)),
$2,
valid_contexts.id,
ST_Area(valid_contexts.geom),
'login fonction fill_contextes_projets'
FROM (
SELECT c.id AS id,
ST_Multi(ST_CollectionExtract(ST_Intersection($3, ST_MakeValid(c.geom)), 3)) AS geom
FROM %I.%I AS c
WHERE ST_Intersects(c.geom, $3)
) AS valid_contexts
WHERE NOT ST_IsEmpty(valid_contexts.geom)
$SQL$,
contexte.nom_schema, contexte.nom_table
)
USING id_projet, contexte.code, geom_projet;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Please use only parameters inside the format method and avoid using also USING
  • Please use %L and not %s
  • Use also number to better identify each parameter, ex %1$L

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants