Skip to content

Upsert Returns 409 (Conflict) on Subsequent Requests #40

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
cliftonlabrum opened this issue Mar 28, 2023 · 0 comments · Fixed by #44
Closed

Upsert Returns 409 (Conflict) on Subsequent Requests #40

cliftonlabrum opened this issue Mar 28, 2023 · 0 comments · Fixed by #44
Labels
bug Something isn't working

Comments

@cliftonlabrum
Copy link

I'm using version 0.2.1 of this package via Swift Package Manager.

I have a user table with a primary key of id. I perform the following upsert query:

let data = MyModel(id: "abc", name: "Bob")

let query = supabase.database.from("user").upsert(values: data, returning: .minimal).select()

do {
  try await query.execute()
} catch {
  print(error)
}

✅ With no records in my table, the upsert succeeds by inserting a new row.
⛔️ If I immediately perform the same query again, I get a 409 error which means there's a conflict.

I assume this is because it's attempting to re-insert the same record again without doing an update instead.

Does upsert() work for anyone else and I'm just doing it wrong? 😅

@cliftonlabrum cliftonlabrum added the bug Something isn't working label Mar 28, 2023
@grdsdev grdsdev transferred this issue from supabase/supabase-swift Apr 2, 2023
@grdsdev grdsdev mentioned this issue Apr 2, 2023
@grdsdev grdsdev linked a pull request Jul 14, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant