Category: Supabase and databases

Supabase PGRST116: .single() Returns No Rows

Read this guide in Polish

Call .single() returns PGRST116 and no single object message. The .single() method expects exactly one record, but the query could return zero or more than one.

How to determine the source of the error

Check column filter and result of the same query without .single().

Compare the assumption of uniqueness of the record with actual data and RLS policies.

What to do step by step

1. If zero records are business acceptable, use .maybeSingle() with separate null support.

2 . If there must be exactly one record, repair the data or add an appropriate limitation of uniqueness in the database.

How to check the score

An empty result does not generate an unserviced exception, and two records for a unique identifier are detected.

What to do

Don't silence everyone PGRST116 as null if no record means data loss.