-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update_form_change now handles the case when form data operator …
…is null and form is currently archived. Sets it to updated.
- Loading branch information
1 parent
e55b105
commit a2a8c95
Showing
7 changed files
with
115 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
-- Deploy cif:mutations/update_form_change to pg | ||
|
||
begin; | ||
|
||
create or replace function cif.update_form_change(row_id int, form_change_patch cif.form_change) | ||
returns cif.form_change | ||
as | ||
$$ | ||
|
||
update cif.form_change set | ||
new_form_data = coalesce(form_change_patch.new_form_data, new_form_data), | ||
operation = coalesce(form_change_patch.operation, operation), | ||
validation_errors = coalesce(form_change_patch.validation_errors, validation_errors), | ||
change_status = 'pending' | ||
where id=row_id | ||
returning *; | ||
|
||
$$ language sql volatile; | ||
|
||
grant execute on function cif.update_form_change to cif_internal, cif_external, cif_admin; | ||
|
||
comment on function cif.update_form_change(int, cif.form_change) is 'Custom mutation that sets the change status to pending on every form_change update'; | ||
|
||
commit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,24 @@ | ||
-- Revert cif:mutations/update_form_change from pg | ||
-- Deploy cif:mutations/update_form_change to pg | ||
|
||
begin; | ||
|
||
drop function cif.update_form_change; | ||
create or replace function cif.update_form_change(row_id int, form_change_patch cif.form_change) | ||
returns cif.form_change | ||
as | ||
$$ | ||
|
||
update cif.form_change set | ||
new_form_data = coalesce(form_change_patch.new_form_data, new_form_data), | ||
operation = coalesce(form_change_patch.operation, operation), | ||
validation_errors = coalesce(form_change_patch.validation_errors, validation_errors), | ||
change_status = 'pending' | ||
where id=row_id | ||
returning *; | ||
|
||
$$ language sql volatile; | ||
|
||
grant execute on function cif.update_form_change to cif_internal, cif_external, cif_admin; | ||
|
||
comment on function cif.update_form_change(int, cif.form_change) is 'Custom mutation that sets the change status to pending on every form_change update'; | ||
|
||
commit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- Revert cif:mutations/update_form_change from pg | ||
|
||
begin; | ||
|
||
drop function cif.update_form_change; | ||
|
||
commit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- Verify cif:mutations/update_form_change on pg | ||
|
||
begin; | ||
|
||
select pg_get_functiondef('cif.update_form_change(int, cif.form_change)'::regprocedure); | ||
|
||
rollback; |