Skip to content

parity(postgrest): fix maybeSingle() for all HTTP methods [from supabase-js] #240

Open

Description

@grdsdev

Warning

Auto-generated by AI — This issue was automatically created by an AI-based SDK parity analysis tool. It may not be applicable to this SDK or may already be implemented in a different form. Please use your best judgment before accepting or closing this issue.

SDK Parity: C# implementation needed

A change was made in supabase-js that needs to be implemented in this repository for SDK parity.

Reference Implementation (supabase-js)

What Changed

maybeSingle() was previously only partially fixed for GET requests. The fix removes the Accept header override inside maybeSingle() itself and instead handles the PGRST116 "0 rows" case uniformly for all HTTP methods (GET, POST/insert, PATCH/update, DELETE, etc.).

Code Reference

// Before: maybeSingle() only set Accept header for GET
if (this.method === 'GET') {
  this.headers.set('Accept', 'application/json')
} else {
  this.headers.set('Accept', 'application/vnd.pgrst.object+json')
}

// After: Accept header override removed from maybeSingle()
// Handle PGRST116 uniformly for all methods in builder
if (this.isMaybeSingle && Array.isArray(data)) {
  // normalize to single or null
}

Implementation Guidance

Expected API Surface (C#)

// Should work for all methods
var result = await supabase.From<Message>()
    .Insert(new Message { Content = "hello" }, new QueryOptions { Returning = ReturnType.Representation })
    .Single(); // MaybeSingle equivalent
// Returns single row or null, no exception when 0 rows

Key Behaviors to Match

  • Returns null (not an exception) when 0 rows for any HTTP method
  • Returns the single row when exactly 1 row is returned
  • Returns error/throws when more than 1 row is returned
  • Works for GET (select), POST (insert+select), PATCH (update+select), DELETE (returning)

Acceptance Criteria

  • MaybeSingle() / Single() works for non-GET methods
  • Returns null (not exception) when 0 rows
  • Throws or returns error when multiple rows returned
  • Unit tests cover all HTTP methods
  • No breaking changes to existing API

Context

  • supabase-js version: v2.100.1
  • Parity tracking: This issue was auto-generated by SDK parity analysis

Generated with Claude Code /sync-sdk-parity

Activity

  1. self-assigned this
    on Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions