Repository navigation
Conversation
@supabase/auth-js
@supabase/functions-js
@supabase/postgrest-js
@supabase/realtime-js
@supabase/storage-js
@supabase/supabase-js
commit: |
mandarini
left a comment
There was a problem hiding this comment.
Hi @Vansh1811, thank you so much for contributing to Supabase! 💚
This is a real, well-reported issue (#2117) and the core approach is correct, converting bigint to string is the standard workaround for JSON.stringify's limitation, and Postgres will coerce a JSON string to int8 just fine inside json_to_record.
Before we can merge this, we need at least one test. There's an rpc.test.ts in packages/core/postgrest-js/test/ that would be the right place for this. At minimum, a unit test that mocks fetch and asserts the serialized body contains the string representation of the bigint. Ideally, an integration test against an actual Postgres function with an int8 parameter -- you can add the function to test/supabase/migrations/00000000000000_schema.sql.
There's also one edge case worth thinking through: if a user passes a bigint value inside a jsonb parameter (e.g., { payload: { id: 9999n } } for an RPC that takes a jsonb), the bigint becomes a JSON string rather than a JSON number. That may or may not be the right behavior, but it should be either tested or called out in a comment so the tradeoff is explicit.
Could you add the tests and take a look at the jsonb case? Happy to help if you have questions about the test setup.
Thank you so much for contributing to Supabase, it's exactly this kind of fix that makes the SDK more reliable for real-world use cases.
ah, noticed this has been also waiting for a bit now ~(7-10d) |
|
sure @7ttp go ahead! |
here you go: |
|
Closing in favor of #2245 |
Description
What changed?
Added a
bigintserialization replacer toJSON.stringifyinPostgrestBuilder.ts. When the request body is serialized, anybigintvalue is now converted to its string representation instead of throwing aTypeError.One-line change:
Why was this change needed?
JavaScript's
JSON.stringifydoes not natively supportbigintvalues and throws:This means any user calling
rpc()with abigintargument (e.g., forint8/bigintPostgres columns) had to manually call.toString()on every bigint value:This approach is consistent with how many serialization libraries handle
bigintand avoids a breaking change —bigint→ string conversion matches what PostgREST expects forint8parameters anyway.Closes #2117