iCyberon / pg_hashids

Short unique id generator for PostgreSQL, using hashids
MIT License
280 stars 24 forks source link

bigserial return {id} #10

Closed nikoz84 closed 7 years ago

nikoz84 commented 7 years ago

Hi, thanks for your extension, its very usefull, i'm try to decode and the result its correct. But the return is between keys {15456}, the field is defined like a bigserial. You have any idea?

iCyberon commented 7 years ago

Hey @nikoz84, could you please give me a sample?

Edit

I think the reason is that id_decode returns Array. You can use id_decode_once to get just one item.

Example

SELECT id_decode_once('3GJ956J9B9', 'This is my salt', 10, 'abcdefghijABCDxFGHIJ1234567890');
nikoz84 commented 7 years ago

Look this example

SELECT id_encode(1001); -- Result: jNl

SELECT id_decode('jNl'); -- Result: jNl

image example in my repo

SELECT id_decode('0pMnYQxnR4', 'Pat20170831', 10);

nikoz84 commented 7 years ago

You have a reason SELECT id_decode_once('0pMnYQxnR4', 'Pat20170831', 10);

the result was : 119

iCyberon commented 7 years ago

@nikoz84 I have not updated the readme yet.

id_decode - returns array bigint[]. id_decode_once - returns just one (first) number bigint.

_P.S. If you're having trouble identifying which function does what you can refer to https://github.com/iCyberon/pg_hashids/blob/master/pg_hashids--1.2.sql file._

Let me know if you need anything else :)

nikoz84 commented 7 years ago

Thank you for your time and your usefull extension...