supabase-community / postgrest-py

PostgREST client for Python. This library provides an ORM interface to PostgREST

Home Page:https://postgrest-py.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Upsert on conflict

mansueli opened this issue · comments

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.

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