Fix updating of fk_main_wastewater_node/fk_main_cover #388
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When creating the functions
tww_app.wastewater_structure_update_fk_main_wastewater_node
/tww_app.wastewater_structure_update_fk_main_cover
, the idea was to call them only in obj_id mode if a structure has no fk_main_wastewater_node/fk_main_cover.Now, we intend to use them in trigger functions regardless whether the
fk_main_wastewater_node
/fk_main_cover
is NULL or not. This poses a problem as the function sets thefk_main_xxx
to the min value of all cover/node oids linked to the wastewater structure. If I have a main cover that has a higher OID than a secondary one, the triggers will overwrite that setting on wastewater structure when altering any cover attribute.To mitigate that problem,when calling
tww_app.wastewater_structure_update_fk_main_xxx(obj_id)
we now only update the main cover/wastewater_node if the value is NULL. Callingtww_app.wastewater_structure_update_fk_main_xxx(NULL)
continues to set it for all where fk_main_xxx is NULL, callingtww_app.wastewater_structure_update_fk_main_xxx(NULL,true)
overwrites the fk_main_xx for all entries