Skip to content

Upsert on conflict #139

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

Closed
mansueli opened this issue Jul 12, 2022 · 1 comment · Fixed by #142
Closed

Upsert on conflict #139

mansueli opened this issue Jul 12, 2022 · 1 comment · Fixed by #142
Labels
enhancement New feature or request

Comments

@mansueli
Copy link
Member

It should be possible to use upsert on conflict in supabase-py/postgrest-py client:

https://supabase.com/docs/reference/javascript/upsert#upsert-your-data

const { data, error } = await supabase
  .from('users')
  .upsert({ username: 'supabot' }, { onConflict: 'username' })

Right now, if you are upserting but the ID is auto-generated, then you end up with duplicated entries in the table.
Upsert on conflict allows you to prevent duplicated rows based on other columns.

@anand2312 anand2312 added the enhancement New feature or request label Jul 12, 2022
@Oisangui
Copy link
Contributor

Oisangui commented Jul 15, 2022

I implemented the solution locally but I'm unable to do pull requests. How should I go about this?

UPDATE
I have created a pull request that solves this. #142

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

Successfully merging a pull request may close this issue.

3 participants