1
[Supabase-js] Allow `select` when inserting and getting error 23505
Source: supabase/supabase#39078 · opened by @JFGHT
Summary Allow a pattern where an insert that fails because of a unique constraint violation (e.g. 23505) automatically falls back to select to return the conflicting row, without requiring a second round-trip. --- Problem Currently, when calling: if the unique_hash column has a unique constraint and the row already exists, the call fails with: At this point: • I don’t get the existing row’s data. • I have to make a second query (.select().eq('unique_hash', value)) to fetch it. This adds complexity and latency for a very common “get or create” use case. --- Proposed solution Introduce a way to tell Supabase JS: > “Try insert. If it fails because of duplicate key, return the existing row instead.” Possible API ideas: Option 1 – Insert with conflict fallback • If row is inserted → return it. • If conflict → fetch and return the existing row (by unique_hash). Option 2 – Extend upsert Righ…
No pledges yet. Be the first to back this.
Comments
Similar requests
[Supabasejs] support modify fetch option in http request
2 votes · 0 comments
Standardize Error Codes Across Supabase Ecosystem
1 vote · 0 comments
Send error codes for errors
3 votes · 0 comments
Make `error` codes non-optional for better error handling on the client side
4 votes · 0 comments
Snowflake wrapper does not quote identifiers, causing failures with mixed-case column names
1 vote · 0 comments
No comments yet.