diff --git a/src/1_create_hashids_constent_shuffle.sql b/src/1_create_hashids_constent_shuffle.sql index ab3543e..cd54e58 100644 --- a/src/1_create_hashids_constent_shuffle.sql +++ b/src/1_create_hashids_constent_shuffle.sql @@ -1,4 +1,4 @@ -drop function if exists hashids.consistent_shuffle(text, text); +DROP FUNCTION if exists hashids.consistent_shuffle(text, text); CREATE OR REPLACE FUNCTION hashids.consistent_shuffle ( diff --git a/src/2_create_hashids_setup_seps.sql b/src/2_create_hashids_setup_seps.sql index f4bc35c..79b2b09 100644 --- a/src/2_create_hashids_setup_seps.sql +++ b/src/2_create_hashids_setup_seps.sql @@ -1,5 +1,5 @@ -create or replace function hashids.clean_seps_from_alphabet( +CREATE OR REPLACE FUNCTION hashids.clean_seps_from_alphabet( p_seps text, p_alphabet text ) @@ -32,7 +32,7 @@ $$ LANGUAGE plpgsql IMMUTABLE COST 200; -create or replace function hashids.clean_alphabet_from_seps( +CREATE OR REPLACE FUNCTION hashids.clean_alphabet_from_seps( p_seps text, p_alphabet text ) diff --git a/src/4_create_hashids_hash.sql b/src/4_create_hashids_hash.sql index 6b1b5d0..9145e6d 100644 --- a/src/4_create_hashids_hash.sql +++ b/src/4_create_hashids_hash.sql @@ -1,4 +1,4 @@ -drop function if exists hashids.hash(bigint, text, boolean); +DROP FUNCTION if exists hashids.hash(bigint, text, boolean); CREATE OR REPLACE FUNCTION hashids.hash( p_input bigint, diff --git a/src/6_create_hashids_encode_list.sql b/src/6_create_hashids_encode_list.sql index 7a0b811..29c9419 100644 --- a/src/6_create_hashids_encode_list.sql +++ b/src/6_create_hashids_encode_list.sql @@ -1,15 +1,15 @@ -drop function if exists hashids.encode_list(bigint[], text, integer, text, boolean); -drop function if exists hashids.encode_list(bigint[], text, integer, text); -drop function if exists hashids.encode_list(bigint[], text, integer); -drop function if exists hashids.encode_list(bigint[], text); -drop function if exists hashids.encode_list(bigint[]); +DROP FUNCTION if exists hashids.encode_list(bigint[], text, integer, text, boolean); +DROP FUNCTION if exists hashids.encode_list(bigint[], text, integer, text); +DROP FUNCTION if exists hashids.encode_list(bigint[], text, integer); +DROP FUNCTION if exists hashids.encode_list(bigint[], text); +DROP FUNCTION if exists hashids.encode_list(bigint[]); CREATE OR REPLACE FUNCTION hashids.encode_list( in p_numbers bigint[], in p_salt text, -- DEFAULT '', - in p_min_hash_length, -- integer default 0, + in p_min_hash_length integer, -- DEFAULT 0, in p_alphabet text, -- DEFAULT 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', in p_zero_offset boolean DEFAULT true) RETURNS text AS diff --git a/src/7_create_hashids_encode.sql b/src/7_create_hashids_encode.sql index cca3de1..837e89d 100644 --- a/src/7_create_hashids_encode.sql +++ b/src/7_create_hashids_encode.sql @@ -83,7 +83,7 @@ CREATE OR REPLACE FUNCTION hashids.encode( in p_number bigint, in p_salt text, in p_min_hash_length integer, - in p_alphabet text + in p_alphabet text, in p_zero_offset boolean) RETURNS text AS $$ diff --git a/src/8_create_hashids_decode.sql b/src/8_create_hashids_decode.sql index 597fb76..60bd61c 100644 --- a/src/8_create_hashids_decode.sql +++ b/src/8_create_hashids_decode.sql @@ -145,43 +145,3 @@ $$ LANGUAGE plpgsql IMMUTABLE COST 300; -CREATE OR REPLACE FUNCTION hashids.decode( - in p_hash text, - in p_salt text, - in p_min_hash_length integer, - in p_alphabet text) - RETURNS bigint[] AS -$$ - DECLARE - p_numbers ALIAS for $1; - p_salt ALIAS for $2; -- default - p_min_hash_length ALIAS for $3; -- default - p_alphabet ALIAS for $4; -- default - p_zero_offset boolean := true ; -- adding an offset so that this can work with values from a zero based array language -BEGIN - RETURN hashids.decode(p_hash, p_salt, p_min_hash_length, p_alphabet, p_zero_offset); -END; -$$ - LANGUAGE plpgsql IMMUTABLE - COST 300; - -CREATE OR REPLACE FUNCTION hashids.decode( - in p_hash text, - in p_salt text, - in p_min_hash_length integer, - in p_alphabet text - in p_zero_offset boolean) - RETURNS bigint[] AS -$$ - DECLARE - p_numbers ALIAS for $1; - p_salt ALIAS for $2; -- default - p_min_hash_length ALIAS for $3; -- default - p_alphabet ALIAS for $4; -- default - p_zero_offset ALIAS for $5 ; -- adding an offset so that this can work with values from a zero based array language -BEGIN - RETURN hashids.decode(p_hash, p_salt, p_min_hash_length, p_alphabet, p_zero_offset); -END; -$$ - LANGUAGE plpgsql IMMUTABLE - COST 300;