Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle mixed bulk upsert #550

Closed
MaybeThisIsRu opened this issue Sep 13, 2022 · 2 comments
Closed

Handle mixed bulk upsert #550

MaybeThisIsRu opened this issue Sep 13, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@MaybeThisIsRu
Copy link

MaybeThisIsRu commented Sep 13, 2022

Feature request

Is your feature request related to a problem? Please describe.

I'm submitting some form data to Supabase where some data exists already (therefore we have primary key data for it), and some data is new (no primary key data for it).

I'd like to save this data to the database in one go using bulk upsert. Currently attempting to do so results in the following error:

{"code":"PGRST102","details":null,"hint":null,"message":"All object keys must match"}

This is the payload:

[{"x_id":39,"y_id":78,"value":"ABC","id":5},{"x_id":40,"y_id":78,"value":"XYZ"}]

Describe the solution you'd like

Supabase will accept this payload, and handle both new inserts and updates automatically.

Describe alternatives you've considered

Making two Supabase API calls. This is not ideal because the JS library (and the backing Postgres library) do not support transactions either. We can't guarantee that both insert and update go through, or neither do.

@MaybeThisIsRu MaybeThisIsRu added the enhancement New feature or request label Sep 13, 2022
@MaybeThisIsRu
Copy link
Author

Looks like this has been requested before in this thread: supabase/postgrest-js#173 (comment)

@soedirgo
Copy link
Member

Yeah, seems like the same issue as the one you linked. Closing this one in favor of that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants