Skip to content

Commit

Permalink
Update 3_create_hashids_setup_alphabet.sql
Browse files Browse the repository at this point in the history
spaces
  • Loading branch information
Robert Hux committed Apr 18, 2019
1 parent f3f4d0d commit f6e8b13
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/3_create_hashids_setup_alphabet.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 27,12 @@ BEGIN
end if;

-- seps should only contain character present in the passed alphabet
-- p_seps := array_to_string(ARRAY(select chars.cha from (select unnest(regexp_split_to_array(p_seps, '')) as cha intersect select unnest(regexp_split_to_array(p_alphabet, '')) as cha ) as chars order by ascii(cha) desc), '');
-- this doesn't preserve the input order, which is bad
p_seps := hashids.clean_seps_from_alphabet(p_seps, p_alphabet);
-- p_seps := array_to_string(ARRAY(select chars.cha from (select unnest(regexp_split_to_array(p_seps, '')) as cha intersect select unnest(regexp_split_to_array(p_alphabet, '')) as cha ) as chars order by ascii(cha) desc), '');
-- this doesn't preserve the input order, which is bad
p_seps := hashids.clean_seps_from_alphabet(p_seps, p_alphabet);

-- alphabet should not contain seps.
p_alphabet := array_to_string(ARRAY( select chars.cha from (select unnest(regexp_split_to_array(p_alphabet, '')) as cha EXCEPT select unnest(regexp_split_to_array(p_seps, '')) as cha) as chars order by ascii(cha) ), '');
p_alphabet := array_to_string(ARRAY( select chars.cha from (select unnest(regexp_split_to_array(p_alphabet, '')) as cha EXCEPT select unnest(regexp_split_to_array(p_seps, '')) as cha) as chars order by ascii(cha) ), '');

p_seps := hashids.consistent_shuffle(p_seps, p_salt);

Expand Down Expand Up @@ -65,4 65,4 @@ BEGIN
END;
$$
LANGUAGE plpgsql IMMUTABLE
COST 200;
COST 200;

0 comments on commit f6e8b13

Please sign in to comment.