Fix add_services_carousel_slide’s return type from void to integer

This commit is contained in:
jordi fita mas 2024-01-12 19:22:26 +01:00
parent 2033aa91f8
commit 2cbdc21e53
7 changed files with 66 additions and 4 deletions

View File

@ -7,7 +7,9 @@ begin;
set search_path to camper, public; set search_path to camper, public;
create or replace function add_services_carousel_slide(media_id integer, caption text) returns void as drop function if exists add_services_carousel_slide(media_id integer, caption text);
create or replace function add_services_carousel_slide(media_id integer, caption text) returns integer as
$$ $$
insert into services_carousel (media_id, caption) insert into services_carousel (media_id, caption)
values (media_id, coalesce(caption, '')) values (media_id, coalesce(caption, ''))

View File

@ -0,0 +1,25 @@
-- Deploy camper:add_services_carousel_slide to pg
-- requires: roles
-- requires: schema_camper
-- requires: services_carousel
begin;
set search_path to camper, public;
create or replace function add_services_carousel_slide(media_id integer, caption text) returns void as
$$
insert into services_carousel (media_id, caption)
values (media_id, coalesce(caption, ''))
on conflict (media_id) do update
set caption = excluded.caption
returning media_id
;
$$
language sql
;
revoke execute on function add_services_carousel_slide(integer, text) from public;
grant execute on function add_services_carousel_slide(integer, text) to admin;
commit;

View File

@ -1,7 +1,27 @@
-- Revert camper:add_services_carousel_slide from pg -- Deploy camper:add_services_carousel_slide to pg
-- requires: roles
-- requires: schema_camper
-- requires: services_carousel
begin; begin;
drop function if exists camper.add_services_carousel_slide(integer, text); set search_path to camper, public;
drop function if exists add_services_carousel_slide(media_id integer, caption text);
create or replace function add_services_carousel_slide(media_id integer, caption text) returns void as
$$
insert into services_carousel (media_id, caption)
values (media_id, coalesce(caption, ''))
on conflict (media_id) do update
set caption = excluded.caption
returning media_id
;
$$
language sql
;
revoke execute on function add_services_carousel_slide(integer, text) from public;
grant execute on function add_services_carousel_slide(integer, text) to admin;
commit; commit;

View File

@ -0,0 +1,7 @@
-- Revert camper:add_services_carousel_slide from pg
begin;
drop function if exists camper.add_services_carousel_slide(integer, text);
commit;

View File

@ -132,3 +132,4 @@ legal_text [roles schema_camper company user_profile] 2023-12-21T23:29:28Z jordi
legal_text_i18n [roles schema_camper legal_text language] 2023-12-21T23:51:09Z jordi fita mas <jordi@tandem.blog> # Add relation for legal text internationalization legal_text_i18n [roles schema_camper legal_text language] 2023-12-21T23:51:09Z jordi fita mas <jordi@tandem.blog> # Add relation for legal text internationalization
translate_legal_text [roles schema_camper legal_text_i18n] 2023-12-22T00:10:05Z jordi fita mas <jordi@tandem.blog> # Add function to translate legal texts translate_legal_text [roles schema_camper legal_text_i18n] 2023-12-22T00:10:05Z jordi fita mas <jordi@tandem.blog> # Add function to translate legal texts
@v0 2024-01-12T18:16:37Z jordi fita mas <jordi@tandem.blog> # Version 0 @v0 2024-01-12T18:16:37Z jordi fita mas <jordi@tandem.blog> # Version 0
add_services_carousel_slide [add_services_carousel_slide@v0] 2024-01-12T18:17:33Z jordi fita mas <jordi@tandem.blog> # Change add_services_carousel_slides return type from void to integer

View File

@ -11,7 +11,7 @@ set search_path to camper, public;
select has_function('camper', 'add_services_carousel_slide', array['integer', 'text']); select has_function('camper', 'add_services_carousel_slide', array['integer', 'text']);
select function_lang_is('camper', 'add_services_carousel_slide', array['integer', 'text'], 'sql'); select function_lang_is('camper', 'add_services_carousel_slide', array['integer', 'text'], 'sql');
select function_returns('camper', 'add_services_carousel_slide', array['integer', 'text'], 'void'); select function_returns('camper', 'add_services_carousel_slide', array['integer', 'text'], 'integer');
select isnt_definer('camper', 'add_services_carousel_slide', array['integer', 'text']); select isnt_definer('camper', 'add_services_carousel_slide', array['integer', 'text']);
select volatility_is('camper', 'add_services_carousel_slide', array['integer', 'text'], 'volatile'); select volatility_is('camper', 'add_services_carousel_slide', array['integer', 'text'], 'volatile');
select function_privs_are('camper', 'add_services_carousel_slide', array['integer', 'text'], 'guest', array[]::text[]); select function_privs_are('camper', 'add_services_carousel_slide', array['integer', 'text'], 'guest', array[]::text[]);

View File

@ -0,0 +1,7 @@
-- Verify camper:add_services_carousel_slide on pg
begin;
select has_function_privilege('camper.add_services_carousel_slide(integer, text)', 'execute');
rollback;