FeatureFuel
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.

Make a pledge

Pledge your monetary support if this feature is added.

$

Comments

No comments yet.

Replying to

Add a comment

What do you think about this feature request?


Similar requests