postgrest-py
postgrest-py copied to clipboard
Upsert on conflict
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. https://github.com/supabase-community/postgrest-py/pull/142