Some checks failed
Deploy MineGeo to Dokploy / deploy (push) Failing after 6m4s
33 lines
1.4 KiB
PL/PgSQL
33 lines
1.4 KiB
PL/PgSQL
-- The original U& expression doubled its Unicode escapes, so the regex
|
|
-- interpreted code-point text as a character range and rejected normal names.
|
|
alter table public.difficulty_presets
|
|
drop constraint difficulty_presets_name_check;
|
|
alter table public.difficulty_presets
|
|
add constraint difficulty_presets_name_check check (
|
|
name = btrim(name)
|
|
and length(name) between 2 and 40
|
|
and name !~ U&'[\0001-\001F\007F-\009F\202A-\202E\2066-\2069]'
|
|
);
|
|
|
|
-- A PL/pgSQL CASE without ELSE raises case_not_found for every saved UUID,
|
|
-- before reaching the custom-preset lookup below it.
|
|
create or replace function public.resolve_difficulty_preset(p_id text)
|
|
returns jsonb language plpgsql stable security invoker set search_path = '' as $$
|
|
declare preset jsonb;
|
|
begin
|
|
case p_id
|
|
when 'easy' then
|
|
return jsonb_build_object('id', 'easy', 'name', 'Easy', 'seconds', 180, 'zoom', true);
|
|
when 'normal' then
|
|
return jsonb_build_object('id', 'normal', 'name', 'Normal', 'seconds', 90, 'zoom', true);
|
|
when 'hard' then
|
|
return jsonb_build_object('id', 'hard', 'name', 'Hard', 'seconds', 30, 'zoom', false);
|
|
else null;
|
|
end case;
|
|
select jsonb_build_object('id', p.id::text, 'name', p.name, 'seconds', p.seconds, 'zoom', p.zoom)
|
|
into preset from public.difficulty_presets p where p.id::text = lower(p_id);
|
|
if not found then raise exception 'Choose a saved difficulty'; end if;
|
|
return preset;
|
|
end;
|
|
$$;
|