2

Postgres' bigint type holds 64 bit integers. But the Supabase JS library returns those values as JS numbers, which cannot safely store 64 bit integers AFAIK. What would be the correct way to handle 64 bit integers in Supabase?

2
  • 1
    Store it as a string? Nov 23, 2022 at 15:31
  • @DaneBrouwer Are you telling me to store it as a string in Postgres? But using a bigint would be a lot more performant than using strings right? I plan to use that column as the primary key too. Nov 23, 2022 at 15:45

1 Answer 1

2

You are correct. This is because numbers in JS are float64, so if your number is more than Number.MAX_SAFE_INTEGER === 9007199254740991. It won't be represented correctly.

An alternative is to cast it to text during the call & manually convert it:

supabase.from('table_name').select('id, num::text');
BigInt(data);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.