Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Hux committed Apr 18, 2019
2 parents d238294 ed0e146 commit 78e85c0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 27 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;
17 changes: 0 additions & 17 deletions src/4_create_hashids_hash.sql
Original file line number Diff line number Diff line change
@@ -1,5 1,4 @@
drop function if exists hashids.hash(bigint, text, boolean);
drop function if exists hashids.hash(integer, text, boolean);

CREATE OR REPLACE FUNCTION hashids.hash(
p_input bigint,
Expand Down Expand Up @@ -35,20 34,4 @@ $$
LANGUAGE plpgsql IMMUTABLE
COST 250;

CREATE OR REPLACE FUNCTION hashids.hash(
p_input integer,
p_alphabet text,
p_zero_offset boolean DEFAULT true)
RETURNS text AS
$$
DECLARE
p_input ALIAS for $1;
p_alphabet ALIAS for $2;
p_zero_offset ALIAS for $3; -- adding an offset so that this can work with values from a zero based array language
BEGIN
RETURN hashids.hash(p_input::bigint, p_alphabet, p_zero_offset);
END;
$$
LANGUAGE plpgsql IMMUTABLE
COST 250;

5 changes: 0 additions & 5 deletions src/8_create_hashids_decode.sql
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 95,6 @@ $$
CREATE OR REPLACE FUNCTION hashids.decode( in p_hash text )
RETURNS bigint[] AS
$$
-- Options Data - generated by hashids-tsql
DECLARE
p_numbers ALIAS for $1;
p_salt text := ''; -- default
Expand All @@ -114,7 113,6 @@ CREATE OR REPLACE FUNCTION hashids.decode(
in p_salt text)
RETURNS text AS
$$
-- Options Data - generated by hashids-tsql
DECLARE
p_numbers ALIAS for $1;
p_salt ALIAS for $2; -- default
Expand All @@ -134,7 132,6 @@ CREATE OR REPLACE FUNCTION hashids.decode(
in p_min_hash_length integer)
RETURNS bigint[] AS
$$
-- Options Data - generated by hashids-tsql
DECLARE
p_numbers ALIAS for $1;
p_salt ALIAS for $2; -- default
Expand All @@ -155,7 152,6 @@ CREATE OR REPLACE FUNCTION hashids.decode(
in p_alphabet text)
RETURNS bigint[] AS
$$
-- Options Data - generated by hashids-tsql
DECLARE
p_numbers ALIAS for $1;
p_salt ALIAS for $2; -- default
Expand All @@ -177,7 173,6 @@ CREATE OR REPLACE FUNCTION hashids.decode(
in p_zero_offset boolean)
RETURNS bigint[] AS
$$
-- Options Data - generated by hashids-tsql
DECLARE
p_numbers ALIAS for $1;
p_salt ALIAS for $2; -- default
Expand Down

0 comments on commit 78e85c0

Please sign in to comment.