Skip to content

Commit

Permalink
fix safe select for inserts
Browse files Browse the repository at this point in the history
  • Loading branch information
thoomasbro committed Dec 19, 2023
1 parent 84c63e2 commit cf6345a
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ INSERT INTO env_actions_control_plan_themes (env_action_id, theme_id)
id as env_action_id,
jsonb_array_elements(value->'themes')->>'theme' as theme
FROM env_actions
WHERE value->>'themes' is not null
)
SELECT DISTINCT themes.env_action_id, th.id
FROM themes,
Expand All @@ -100,6 +101,7 @@ INSERT INTO env_actions_control_plan_sub_themes (env_action_id, subtheme_id)
jsonb_array_elements(value->'themes')->>'theme' as theme,
jsonb_array_elements_text(jsonb_array_elements(value->'themes')->'subThemes') as subtheme
FROM env_actions
WHERE value->>'themes' is not null
)
SELECT DISTINCT themes.env_action_id, sbt.id
FROM themes,
Expand All @@ -119,6 +121,7 @@ WITH themes AS (
jsonb_array_elements(value->'themes')->>'protectedSpecies' as protectedspeciestext,
jsonb_array_elements(value->'themes')->'protectedSpecies' as protectedspecies
FROM env_actions
WHERE value->>'themes' is not null
)
SELECT DISTINCT themes.env_action_id, control_plan_tags.id
FROM themes,
Expand Down

0 comments on commit cf6345a

Please sign in to comment.